After ssh
-ing into our host, do the following:
-
Ensure that you are currently in your home directory by running
cd ~/
. -
Run
vi ~/.bash_profile
. This command translates to "edit this text file in the vim text editor" -
Once you're in the text editor, press
i
to go into insert mode. -
Copy/paste the block of code below into your file:
# reload bash alias rb=". ~/.bash_profile" # get to home directory from anywhere alias home="cd ~/" # edit bash profile alias eb="vi ~/.bash_profile" # connect to the database alias db="psql -U postgres" # list databases alias db_list="psql -U postgres -l" # check db status alias db_status="service postgresql status" # start db alias db_start="service postgresql start" # stop db alias db_stop="service postgresql stop" # shows the columns for the given table, otherwise only the tables are listed function db_col() { psql -U postgres -c "\d $1" } # deletes a database when given the database's name as an argument function db_deldb() { psql -U postgres -c "DROP DATABASE $1;" }
-
To save your changes, press the 'Esc' key then hold the 'Shift' key and press 'z' twice. This will save your changes and exit out of the text editor. (Esc + Shift ZZ).
-
Finally, simply enter
. ~/.bash_profile
so that bash picks up your new shortcuts.