DEV Community

loading...
Cover image for Useful Alias for ZSH

Useful Alias for ZSH

equiman profile image Camilo Martinez Updated on ・2 min read

When I start working all the machines in my office use Windows. That's the moment when I start missing the alias ability that I learned at the university where I used to have Linux on my laptop.

Happily now, ZSH (or bash) can be used on Linux, macOS, and Windows (with WSL).

In addition to all the aliases that can be activated with ZSH plugins, I've defined a lot more that I miss. Hope also can be useful for you.


General

alias c="clear"
alias x="exit" # close terminal
alias e="code -n ~/.zshrc" # edit source
alias r="source ~/.zshrc" # reload source
alias t="htop"
alias d="ncdu --color dark" # +path
Enter fullscreen mode Exit fullscreen mode

History

alias h="history -10" # last 10 history commands
alias hc="history -c" # clear history
alias hg="history | grep " # +command
Enter fullscreen mode Exit fullscreen mode

history-grep

Alias

alias ag="alias | grep " # +command
Enter fullscreen mode Exit fullscreen mode

alias-grep

Git

⚠ Use this alias with extra caution, you may lose all your changes.

alias guc="git reset --hard HEAD" # undo changes and preserve untracked files
alias gcc="git clean -f -d -x" # clean ALL changes and remove untracked files
Enter fullscreen mode Exit fullscreen mode

I'm not set up the global user and mail on git because I work on different projects. So I have an alias with the most used user.

alias gcu="git config user.name \"equiman\" && git config user.email \"equiman@users.noreply.github.com\""
Enter fullscreen mode Exit fullscreen mode

npm

alias rnm="rm -rf node_modules"
alias rbn="rm -rf build node_modules"
alias rap="rm -rf build node_modules package-lock.json && npm i"

alias npk="npx npkill" #clean unused node_modules
alias nlg="npm list -g --depth 0" #list global packages installed

alias ni="npm i"
alias nise="npm i -S -E " # +package@version
alias nide="npm i -D -E " # +package@version

alias nrb="npm run build"
alias nrbd="npm run build:dev"
alias nrs="npm run start"
alias nrsd="npm run start:dev"
alias nrt="npm run test"

alias np="npm run build && npm publish"
alias nu="npm unpublish " # +package@version
Enter fullscreen mode Exit fullscreen mode

Serverless

alias sd="sls deploy"
alias sdf="sls deploy -f " # +function_name
Enter fullscreen mode Exit fullscreen mode

That’s All Folks!
Happy Coding 🖖

Buy me a cofee

Discussion (1)

pic
Editor guide
Collapse
dasginger profile image
DasGinger

Cheers! Thanks for the quick aliases.