How to configure alias in Zsh?
Whether you use Mac OSX or Linux, you utilise the terminal or shell a lot as a developer. Some commands are simply excessively long, laborious, and ineffective when used frequently. These can be condensed by using Command aliases in Zsh or Bash.
For example:
1
alias rs4="rails server --port=4000"
By using above, we can start a rails server at port 4000 with an alias command rs4
.
To configure aliases, edit your zshrc
and source it again after adding aliases.
1
2
vi ~/.zshrc
source ~/.zshrc
I have loads of aliases and some of them are:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#-------------------------------------------------------------
# Ruby, Ruby on Rails
#-------------------------------------------------------------
alias rr="rails routes"
alias rre="rails routes --expanded"
alias rc="rails console"
alias rs="rails server"
alias rsd="rails server --debugger"
alias rs4="rails server --port=4000"
alias rs5="rails server --port=5001"
alias sq="sidekiq -C config/sidekiq.yml"
alias wp="./bin/webpack-dev-server"
alias bd="./bin/dev"
#-------------------------------------------------------------
# Git
#-------------------------------------------------------------
alias status="git status"
alias gffs="git flow feature start"
alias gfff="git flow feature finish"
alias ga="git add ."
alias gcm="git commit -a"
alias gcam="git commit -am"
alias master="git checkout master"
alias gpullm="git pull origin master"
alias gpushm="git push origin master"
alias production="git checkout production"
alias gpullp="git pull origin production"
alias gpushp="git push origin production"
alias develop="git checkout develop"
alias gpulld="git pull origin develop"
alias gpushd="git push origin develop"
alias gmd="git merge develop"
alias gmm="git merge master"
alias gmp="git merge production"
#-------------------------------------------------------------
# Heroku
#-------------------------------------------------------------
alias gphm="git push heroku master"
alias hprecompile="heroku run rake assets:precompile"
alias hmigrate="heroku run rake db:migrate"
alias hjobswork="heroku run rake jobs:work"
alias hrestart="heroku restart"
alias ho="heroku open"
#-------------------------------------------------------------
# Teraform
#-------------------------------------------------------------
alias tfv="terraform --version"
alias tfi="terraform init"
alias tfp="terraform plan"
alias ts="tfswitch"
#-------------------------------------------------------------
# Jekyll
#-------------------------------------------------------------
alias jd="jekyll draft"
alias jp="jekyll publish"
alias js="jekyll server"
alias jsd="jekyll server --watch --drafts"
#-------------------------------------------------------------
# Others
#-------------------------------------------------------------
alias p="cd && cd projects/"
alias ezsh="vi ~/.zshrc"
alias szsh="source ~/.zshrc"
Happy coding :)
This post is licensed under CC BY 4.0 by the author.
Comments powered by Disqus.