Bash and zsh aliases: useful shortcuts for .bashrc and .zshrc
Add handy shortcuts and settings to your terminal.
Aliases are short names for long commands. Pick the shortcuts you want below, download the file, and add it to the end of your .bashrc or .zshrc.
Create your config file
Type your own values. The file below updates as you type, and nothing you type leaves your browser.
# Added by localconfig.com
alias ll='ls -alFh'
alias ..='cd ..'
alias ...='cd ../..'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias gs='git status -sb'
alias gl='git log --oneline --graph --decorate'
alias gp='git pull'
alias update='sudo apt update && sudo apt upgrade -y'
mkcd() { mkdir -p "$1" && cd "$1"; }
export EDITOR=nano
export HISTSIZE=10000
export HISTFILESIZE=10000
export SAVEHIST=10000How this setup works
Step-by-step setup
- Download the file and open a terminal in the same folder.
- Add it to the end of your shell file: cat aliases.sh >> ~/.bashrc (zsh users: ~/.zshrc).
- Load it now: source ~/.bashrc.
- Try it: type update or gs.
What the important lines mean
- An alias is a short name for a longer command.
- mkcd is a small function because an alias cannot take a folder name.
- HISTSIZE=10000 sets how many commands your terminal remembers. SAVEHIST is the zsh version of the same setting.
Common errors and how to fix them
- command not found after saving
- Open a new terminal or run source ~/.bashrc. The file only loads when a terminal starts.
- Aliases work in bash but not zsh
- Zsh reads ~/.zshrc. Add the same lines there.
- Alias breaks with a quote error
- Do not use single quotes inside an alias command. The alias command field blocks them.
Frequently asked questions
- Where do I put aliases, .bashrc or .zshrc?
- Use ~/.bashrc if your shell is bash and ~/.zshrc if it is zsh. macOS uses zsh by default.
- Why do my aliases not work after I save?
- The file loads only when a terminal starts. Open a new terminal or run source ~/.bashrc.
- What is the difference between an alias and a function?
- An alias replaces a word with text. A function can take arguments, so use a function when you need to pass something like a folder name.
Free tools that help
- chmod calculatorTick read, write and execute for owner, group and others to get the chmod number, symbolic form and command. Or type 755 and see what it means.
More developer configs
- .gitignore fileTick your languages and tools to get a .gitignore that keeps build files and secrets out of Git.
- .editorconfig fileMake every editor on your team use the same indent, line endings and encoding.
- GitHub Actions workflow for Node.jsA ci.yml file that installs, lints, builds and tests your Node.js project on GitHub.
- package.json fileCreate a package.json with the right name, version, module type, scripts and Node version.
- tsconfig.json fileCreate a tsconfig.json for a Node or browser TypeScript project, with strict mode, target and output folder.
- SSH config for multiple GitHub accountsUse two or three GitHub accounts on one computer with separate SSH keys and host names.