[Bash] Create Aliases in .bash_profile for Common Bash Commands

.bash_profile is a file that bash invokes (or more technically sources) before the start of a new bash session. In .bash_profile, we have the opportunity to add variables, functions, and aliases to customize our bash environment and provide reusable functionality.

In this lesson, we’ll look at adding a git_sync alias as well as a ll alias. Aliases act like shortcuts and save us time and typing at the terminal. .bash_profile is a good spot for smaller functions and aliases.

Note that on most linux distributions you'll use .bashrc instead of .bash_profile.

 

1. cd ~

2. vim .bash_profile

3. Add alias

alias ll="ls -laG"
alias git_sync="git pull -r && git push"

4. apply changes

source .bash_profile

5. To check what the alias does:

$ ll

 

posted @ 2019-03-14 18:00  Zhentiw  阅读(305)  评论(0编辑  收藏  举报