How to create shell aliases for longer commands
If you use the terminal daily, you've probably typed the same long commands over and over. Shell aliases let you create shortcuts so you can stop repeating yourself.
The problem
I use Claude Code regularly, and sometimes I need to run it with the --dangerously-skip-permissions flag. Typing this every time gets old fast:
claude --dangerously-skip-permissions
That's 42 characters. I wanted something I could type without thinking.
The simple solution: aliases
The quickest fix is a plain shell alias. Add this to your ~/.zshrc (or ~/.bashrc if you use bash):
# Claude shortcuts
alias cl="claude"
alias cld="claude --dangerously-skip-permissions"
Then reload your shell:
source ~/.zshrc
That's it. Now:
clrunsclaude(2 characters instead of 6)cldrunsclaude --dangerously-skip-permissions(3 characters instead of 42)
Both accept extra arguments too. cld -m "fix the bug" works exactly like claude --dangerously-skip-permissions -m "fix the bug".
Before you pick a name: check for conflicts
Before creating an alias, make sure the name isn't already taken by another command on your system:
which cl 2>/dev/null
which cld 2>/dev/null
type cl 2>/dev/null
type cld 2>/dev/null
If nothing comes back, you're clear. Avoid overriding built-in commands like cd, ls, or rm unless you know exactly what you're doing.
When you need more control: functions
Aliases work great for simple mappings. But what if you want a subcommand like claude danger? Aliases don't support spaces in names. For that, you need a shell function:
claude() {
if [[ "$1" == "danger" ]]; then
shift
command claude --dangerously-skip-permissions "$@"
else
command claude "$@"
fi
}
This intercepts the first argument. If it's danger, it swaps in the full flag. Otherwise, it passes everything through to the real claude binary unchanged.
The command keyword is important here. It tells the shell to call the actual binary instead of the function recursively.
I ended up going with the simpler cl and cld aliases instead. Fewer keystrokes wins.
Usage examples
# Start claude normally
cl
# Start claude with dangerous mode
cld
# Pass extra arguments
cld -m "fix the auth bug"
cl -m "explain this function"
Apply the pattern to anything
This works for any command you type frequently:
# Docker shortcuts
alias dc="docker compose"
alias dcu="docker compose up -d"
alias dcd="docker compose down"
# Git shortcuts
alias gs="git status"
alias gp="git push"
alias gl="git log --oneline -10"
Start with the commands you type most. Run history | awk '{print $2}' | sort | uniq -c | sort -rn | head -10 to find your most used commands and alias the longest ones.
Shell aliases are one of the simplest productivity wins in the terminal. Three characters instead of forty-two adds up fast.