Shell Configuration and ProductivityLesson 3.2
How to create shell aliases to speed up your workflow
alias syntax, unalias, common developer aliases, alias persistence in .bashrc, alias vs function, quoting in aliases
Shell Aliases
Aliases are shortcuts: you define a short name for a longer command. They save keystrokes and reduce typos for commands you run dozens of times a day.
Alias syntax
alias gs='git status'
alias gp='git push'
alias gc='git commit -m'No spaces around =. Use single quotes to prevent the shell from expanding variables at definition time.
Practical developer aliases
alias ll='ls -lah'
alias ..='cd ..'
alias ...='cd ../..'
alias cls='clear'
alias serve='python3 -m http.server 8000'Making aliases permanent
echo "alias ll='ls -lah'" >> ~/.bashrc
source ~/.bashrcRemoving an alias in the current session
unalias gsWhen to use a function instead
Aliases cannot accept arguments. If you need logic or parameters, use a function:
mkcd() {
mkdir -p "$1" && cd "$1"
}
# Usage: mkcd new-projectAdd functions to .bashrc the same way as aliases.
