• alias设置
    • 系统自带(或者是oh-my-zsh添加的)
    • 手动添加

    alias设置

    alias是一个shell命令,可以理解为别名,就是可以让我们对一些命名重新命名,这样在终端中,我们就可以输入更少的字符完成同样的事情。

    系统自带(或者是oh-my-zsh添加的)

    在终端中输入alias,会得到:

    1. ...=../..
    2. ....=../../..
    3. .....=../../../..
    4. ......=../../../../..
    5. 1='cd -'
    6. 2='cd -2'
    7. 3='cd -3'
    8. 4='cd -4'
    9. 5='cd -5'
    10. 6='cd -6'
    11. 7='cd -7'
    12. 8='cd -8'
    13. 9='cd -9'
    14. _=sudo
    15. a='fasd -a'
    16. afind='ack-grep -il'
    17. d='fasd -d'
    18. f='fasd -f'
    19. g=git
    20. ga='git add'
    21. gaa='git add --all'
    22. gap='git add --patch'
    23. gb='git branch'
    24. gba='git branch -a'
    25. gbr='git branch --remote'
    26. gc='git commit -v'
    27. 'gc!'='git commit -v --amend'
    28. gca='git commit -v -a'
    29. 'gca!'='git commit -v -a --amend'
    30. gcl='git config --list'
    31. gclean='git reset --hard && git clean -dfx'
    32. gcm='git checkout master'
    33. gcmsg='git commit -m'
    34. gco='git checkout'
    35. gcount='git shortlog -sn'
    36. gcp='git cherry-pick'
    37. gcs='git commit -S'
    38. gd='git diff'
    39. gdc='git diff --cached'
    40. gdt='git difftool'
    41. gg='git gui citool'
    42. gga='git gui citool --amend'
    43. ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
    44. ggpull='git pull origin $(current_branch)'
    45. ggpur='git pull --rebase origin $(current_branch)'
    46. ggpush='git push origin $(current_branch)'
    47. gignore='git update-index --assume-unchanged'
    48. gignored='git ls-files -v | grep "^[[:lower:]]"'
    49. git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
    50. gk='gitk --all --branches'
    51. gl='git pull'
    52. glg='git log --stat --max-count=10'
    53. glgg='git log --graph --max-count=10'
    54. glgga='git log --graph --decorate --all'
    55. glo='git log --oneline --decorate --color'
    56. globurl='noglob urlglobber '
    57. glog='git log --oneline --decorate --color --graph'
    58. glp=_git_log_prettily
    59. gm='git merge'
    60. gmt='git mergetool --no-prompt'
    61. gp='git push'
    62. gpoat='git push origin --all && git push origin --tags'
    63. gr='git remote'
    64. grba='git rebase --abort'
    65. grbc='git rebase --continue'
    66. grbi='git rebase -i'
    67. grep='grep --color=auto --exclude-dir={.bzr,.cvs,.git,.hg,.svn}'
    68. grh='git reset HEAD'
    69. grhh='git reset HEAD --hard'
    70. grmv='git remote rename'
    71. grrm='git remote remove'
    72. grset='git remote set-url'
    73. grt='cd $(git rev-parse --show-toplevel || echo ".")'
    74. grup='git remote update'
    75. grv='git remote -v'
    76. gsd='git svn dcommit'
    77. gsps='git show --pretty=short --show-signature'
    78. gsr='git svn rebase'
    79. gss='git status -s'
    80. gst='git status'
    81. gsta='git stash'
    82. gstd='git stash drop'
    83. gstp='git stash pop'
    84. gsts='git stash show --text'
    85. gts='git tag -s'
    86. gunignore='git update-index --no-assume-unchanged'
    87. gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
    88. gup='git pull --rebase'
    89. gvt='git verify-tag'
    90. gwc='git whatchanged -p --abbrev-commit --pretty=medium'
    91. gwip='git add -A; git ls-files --deleted -z | xargs -r0 git rm; git commit -m "--wip--"'
    92. history='fc -l 1'
    93. l='ls -lah'
    94. la='ls -lAh'
    95. ll='ls -lh'
    96. ls='ls -G'
    97. lsa='ls -lah'
    98. md='mkdir -p'
    99. o='a -e open'
    100. please=sudo
    101. po=popd
    102. pu=pushd
    103. rd=rmdir
    104. run-help=man
    105. s='fasd -si'
    106. sd='fasd -sid'
    107. sf='fasd -sif'
    108. st='open -a "Sublime Text"'
    109. v='f -e vim'
    110. which-command=whence
    111. z='fasd_cd -d'
    112. zz='fasd_cd -d -i'

    这表明mac的终端其实自带了一些alias。当然,我们也可以手动添加。

    手动添加

    自定义的alias应该在终端的配置文件中添加,比如我使用的是zsh,就在.zshrc文件中添加。

    常用的操作有:

    • alias st='open -a "Sublime Text"': 打开sublimeText