https://github.com/theapache64/bash_rc
My bash shortcuts
https://github.com/theapache64/bash_rc
ubuntu
Last synced: 10 months ago
JSON representation
My bash shortcuts
- Host: GitHub
- URL: https://github.com/theapache64/bash_rc
- Owner: theapache64
- License: apache-2.0
- Created: 2017-07-06T07:02:49.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-06T07:08:32.000Z (almost 9 years ago)
- Last Synced: 2025-06-04T08:51:44.543Z (about 1 year ago)
- Topics: ubuntu
- Language: Shell
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bash_rc
My bash shortcuts
To use these shortcuts from your terminal, simply paste the below script above your `~/.bashrc`.
To use SQL shortcuts, fill the empty variables (host,username and password).
```
# Git shortcuts
# eg: push "Your-commit-message"
function push(){
git add -A
git commit -m "$1"
git push origin master
}
# eg: commit "Your-commit-message"
function commit(){
git add -A
git commit -m "$1"
}
# SQL shortcuts
REMOTE_HOST=""
REMOTE_USERNAME=""
REMOTE_PASSWORD=""
LOCAL_USERNAME=""
LOCAL_PASSWORD=""
# To download sql backup from remote
# eg: sql_backup "your-database-name"
function sql_backup(){
dt=$(date '+%d-%m-%Y_%H:%M:%S')
local fn="$1_backup_$dt.sql"
echo "Please wait... the backup is being generated : $fn"
if mysqldump -h"$REMOTE_HOST" -u"$REMOTE_USERNAME" -p"$REMOTE_PASSWORD" "$1" > "$fn"; then
notify-send -i face-smile "SQL Backup finished" "$fn"
else
notify-send -i face-sad "SQL Backup failed!" "$1"
fi
}
# To download sql backup from remote and replace with local
# eg: sql_clone_remote "your-database-name"
function sql_clone_remote(){
dt=$(date '+%d-%m-%Y_%H:%M:%S')
local fn="$1_backup_$dt.sql"
echo "Please wait, the sql file is being downloaded - $fn"
if mysqldump -h"$REMOTE_HOST" -u"$REMOTE_USERNAME" -p"$REMOTE_PASSWORD" "$1" > "$fn"; then
mysql -u"$LOCAL_USERNAME" -p"$LOCAL_PASSWORD" "$1" < "$fn"
notify-send -i face-smile "Synced" "Remote database synced with local"
else
notify-send -i face-sad "SQL Backup failed! : $1"
fi
}
# To upload local database to remote and replace.
# eg: sql_clone_local "your-database-name"
function sql_clone_local(){
dt=$(date '+%d-%m-%Y_%H:%M:%S')
local fn="$1_backup_$dt.sql"
echo "Please wait, the sql file is being uploaded"
if mysqldump -u"$LOCAL_USERNAME" -p"$LOCAL_PASSWORD" "$1" > "$fn"; then
mysql -h"$REMOTE_HOST" -u"$REMOTE_USERNAME" -p"$REMOTE_PASSWORD" "$1" < "$fn"
notify-send -i face-smile "Synced" "Local database synced with remote, LIVE!"
else
notify-send -i face-sad "SQL Backup failed! : $1"
fi
}
```