##Create Aliases in .bash_profile to Assign Shortcuts for Common Terminal Commands
###Instruction: Enter these aliases into your ~/.bash_profile or ~/.zshrc (if using zsh)
- Let’s say you often browse to a directory that requires a lot of typing, such as:
alias cdp="cd ~/Dropbox/projects/source/"
OR
go() { cd ~/Dropbox/projects/source/$1"; }
_go() { _files -W ~/Dropbox/projects/source/ -/; }
compdef _go go
- The problem with ping is that it continues to run after you start it, so you have to cancel it. Alias ping to ping -o to grab only one reply packet and exit—now, ping will display the site's IP address and exit.
alias ping="ping -o"
- Another useful alias you can create is for opening files with your favorite text editor. In my case, it’s Sublime Text 3
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
###A Safer rm
- If you use the rm command to delete files, they're gone forever. Adding the -i flag to rm tells the command to ask you first before deleting the file. I like this layer of cross-checking to help prevent me from accidentally deleting files I want.
alias rm="rm -i"
###Lazy git
function lazygit() {
git add .
git commit -a -m "$1"
git push
}
-This allows you to provide a commit message, such as:
lazygit "My commit msg"
###My Favorites
alias bye="exit" #Users can type "bye" to exit a terminal.
alias BYE="exit" #BASH is case-sensitive, so "bye" is different from "BYE"
alias Exit="exit" #If a user has a bad habit of capitalizing the first letter of commands, this alias will handle that issue
alias EXIT="exit" #This alias helps users that tend to leave caps-lock on.
alias clr="clear" #This is a shortcut for "clear"
alias clsh="clear; history -c; echo \"\" > ~/.bash_history; exit" #This alias command will clear the terminal, delete the history, and exit. The backslashes protect the quotes that are within the aliases coding.
alias del="rm" #Users that are accustomed to using DOS will benefit from an alias that mimics DOS.
alias delete="rm" #This alias allows the user to use a easier-to-remember command to remove files.
alias copy="cp" #This alias also allows a user to use a command that is not as abstract.
alias ...="cd ../.." #This shortcut can save users time. The alias is three key-presses while the original requires eight.
alias sendbeta="bzr push lp:novabot-xaiml; bzr push lp:novabot-xaiml" #To push many projects at once, add each push command separated with a semicolon.
alias coffee="coffeescript" #Coffeescript users can save time by only typing "coffee". If you are still too lazy for that, try the next alias.
alias cs="coffeescript"
alias editalias="(subl ~/.bash_profile)" OR alias editalias="(subl ~/.zshrc)" #Opening a file manager and changing the view settings to show hidden files and then finding the alias file can all be time-consuming. Guess what? Make another time saving alias. Now, users can quickly have the file open for modifications.
alias back="cd -" #To go back to the previous folder location, typing "back" will be quick to use and easy for users to remember.
It's awesome that you're having fun with configuring, documenting and streamlining you environment. Consider creating a
dotfiles
repo with some sort of install script so that if/when you switch computers, restoring is as easy as:git clone my_dotfiles_repo cd my_dotfiles_repo ./install