写在前面的话
命令行(Command Line)一向是每位开发者都要或多或少掌握的功能,而Windows/Mac中的终端(Terminal)可谓非常不同,这篇文章详细的讲解了如何使用Hyper取代Mac上的默认终端,打造一个高颜值(划重点),强大的生产力工具,包括很多便捷功能:自动补全命令,记忆历史命令,文字着色与高亮,显示当前Git分支/标签等。
最终效果如下:
在这篇文章中,作者写的非常详细,就算新手也可以根据他的效果完成Hyper的设置。
【英译中】如何打造一款个人命令行终端:Hyper.js + ZSH + starship ☄️🔥
作者:Thomas Jaskiewicz
原文链接:https://tjay.dev/howto-my-terminal-shell-setup-hyper-js-zsh-starship/
我们每天都要接触终端界面,那怎么让它成为一件具有生产力的工具呢?我们应该使用怎样的终端界面?有什么小技巧可以提高我们使用它的效率呢?
每个开发者在购入新电脑的时候,所做的第一件事大概率都是设置终端环境。在这里,我想与你分享一下我自己在使用的终端环境。
Talk is cheap, let’s show some code.
1. 终端 - Hyper.js
1.1 下载并安装Hyper
先进入Hyper官网下载符合你OS的版本,在这里我下载的是MacOS版本。我们解压Hyper-3.0.2-mac.zip得到Hyper.app文件。只要把它拖入Applications文件夹即可进行安装。现在,使用Spotlight Search功能(CMD + 空格),键入hyper,你应该就可以看见Hpyer这个app在列表里了。
现在Hyper的窗口长这个样子:
如果你的看起来不太一样?不用担心,我们稍后再处理这个,因为一开始你可能用了不同的终端界面,或设置。
1.2 基础设定
现在,来施与一些魔法。Hyper的设置文件在 ~/.hyper.js (笔者:使用命令“open ~/.hyper.js”)路径下。文件看起来像这个样子:
有一些非常酷的内容!可以通过修改这里的字段来随心所欲地设置终端。
先让我们从基础设定开始吧。
1.2.1 字体(Font)
- 字体尺寸(fontSize):个人来说,我比较喜欢稍大一些的字体,我在这里把它调整为13。之后你可以通过“CMD”+“+”和“CMD”+“-”快捷键来调整字体的大小。
- 字型(fontFamily):来试试FiraCode吧,这是一种连体合字类型的字体。下面是一个预览。
安装教程在这里。但我更喜欢手动安装(MacOS环境下):
- 在Github的release页面中下载最新版的字型:Releases · tonsky/FiraCode · GitHub - 在我写这篇文章的时候,最新版是Fira_Code_v5.2.zip 。
- 解压文件,得到ttf文件夹。
- 全选文件夹内的所有.ttf文件,右键,打开,选择安装字体。
现在,字体已经装好并且可以在Hyper中进行设置了。(就像刚才说的那样)设置文件在Home路径下。
在终端中执行:
1 |
nano~/.hyper.js |
现在我们就设置好了FiraCode字型,但是连字还没被开启,现在开启它。
我们需要装一个专门用来干这个的插件 :hyper-font-ligatures。
在终端中执行:
1 |
hyper i hyper-font-ligatures |
插件应该立即出现在你的设置文件中:
然而,为了开启连字,我们还得在设置文件里再多加一行(查阅issue #8和zeit/hyper#3607):
现在,所有的都应该和我们预想的一样了,可以在终端中看到新的连字字型:
1.2.2 主题(Theme)
Hyper可以下载非常多的主题:Hyper Store - Plugins。我们这次用Hyper Store - hyper-one-dark。
在终端中执行:
1 |
hyper i hyper-one-dark |
然后我们界面就会看起来像这样:
1.2.3 搜索插件(Search Plugin)
要开启搜索功能的话,需要安装另一个专门的插件:Hyper Store - hyper-search。
这次需要重启一下Hyper,在重启之后就可以用搜索功能了:
1.2.4 方格导航插件(Pane Navigation Plugin)
为了在不同的区域方格中进行操作,我们需要安装 Hyper Store - hyper -pane。
1 |
hyper i hyper-pane |
怎么运作?
1.2.5 在同一目录中打开新的标签页
总是想在同一路径打开新的标签页?没问题。使用 Hyper Store - hypercwd。
1 |
hyper i hypercwd |
1.2.6 为当前标签页增加图标
每次打开很多标签页时,总是难分清当前标签页是哪一个。有一个插件可以帮助你更好地分辨他们:Hyper Store - hyper-active-tab。
1 |
hyper i hyper-active-tab |
然后自己设置一个图标:
就会变成这样子:
1.2.7 显示CPU,内存和电池状态
增加这个插件 GitHub - Hyperline/hyperline: ✨ Status line plugin for Hyper ✨,可以显示CPU,内存和电池状态:
1 |
hyper i hyperline |
重载一下界面(Shit + CMD + R),下面就会显示一行状态栏:
甚至还能显示当前在Spotify播放的歌曲!
1.2.8 Bonus:如此强大的力量!
Javascript几乎允许我们做任何事。来看看这个 Hyper Store - hyperpower!
1 |
hyper i hyperpower |
于是:
与此同时,还有很多有意思的插件正在被开发中。你可以通过这两个地方找到你心仪的插件:
- 官方插件商店: Hyper Store - Plugins
- Github上一个插件列表的仓库: https://github.com/bnb/awesome-hyper
2 Shell - ZSH + starship
在Linux上,有很多界面可以用:
- Bash Shell - Bash (Unix shell) - Wikipedia
- Tcsh/Csh Shell - https://pl.wikipedia.org/wiki/Tcsh
- Ksh Shell - https://pl.wikipedia.org/wiki/Korn_shell
- Zsh Shell - https://pl.wikipedia.org/wiki/Zsh
- Fish - https://pl.wikipedia.org/wiki/Friendly_interactive_shell
尝试了数不清的界面以后,我选择ZSH。
2.1 安装ZSH
在Mac OS下安装:
1 |
brew install zsh |
还没有安装homebrew?没关系,通过以下命令安装它(官方安装文档在这里):
1 |
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install) |
homebrew是macOS上的一个包管理器。
在安装ZSH后,检查一下它的版本号:
1 2 3 4 5 6 |
zsh --version zsh 5.7.1 (x86_64-apple-darwin19.0) which zsh /usr/local/bin/zsh |
为了指定让Hyper使用ZSH,我们需要更新一下设置项(~/.hyper.js):
现在,Hyper重启以后就会默认载入ZSH作为默认的shell,我们可以进行下一步了。
2.2 安装starship
starship是一个提示符(Prompt)拓展,它可以帮助你在shell中标注一些重要信息。再尝试了非常多的拓展之后,这次我们选择 GitHub - starship/starship: ☄️🌌️ The minimal, blazing-fast, and infinitely customizable prompt for any shell! 进行安装。
2.2.1 安装
在官方文档中,介绍了很多方法来安装 GitHub - starship/starship: ☄️🌌️ The cross-shell prompt for astronauts。
在Mac OS下:
1 |
brew install starship |
检查一下安装是否完成:
1 2 |
starship --version starship 0.44.0 |
为了启用starship,我们还需要在~/.zshrc中添加一些设置项。执行接下来的命令,把设置项加到~/.zshrc的末尾:
1 |
echo 'eval "$(starship init zsh)"' ~/.zshrc |
重启Hyper,就会出现如下界面:
但是!至此为止shell还是没有语法高亮,命令候选,历史记录,别名等种种功能,接下来我们需要调整一下。
2.2.2 语法高亮
GitHub - unixorn/awesome-zsh-plugins: A collection of ZSH frameworks, plugins & themes inspired by the various awesome list collections out there是一个Github上面ZSH插件的综合仓库。来找个语法高亮插件吧!
这次安装用“克隆仓库”的方式(这有助于以后的版本更新):
1 2 3 4 5 6 7 8 9 10 11 |
# Create a `.zsh` directory to store our plugins in one place mkdir ~/.zsh # Clone repo to `~/.zsh/` directory cd ~/.zsh && git clone git@github.com:zdharma/fast-syntax-highlighting.git # Enable 'fast-syntax-highlighting' plugin in ZSH echo "source $HOME/.zsh/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh" ~/.zshrc # Reload ZSH source ~/.zshrc |
但是也有可能会执行失败:
1 |
git@github.com: Permission denied (publickey) |
请使用Https的方式进行克隆:
1 |
git clone https://github.com/zdharma/fast-syntax-highlighting.git |
再一系列的安装步骤后,语法高亮就被开启了:
2.2.3 命令候选
GitHub - robbyrussell/oh-my-zsh 里有一个定义好的completion.zsh文件:
1 2 3 4 5 6 7 |
# Download completion config cd ~/.zsh && wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/lib/completion.zsh # Enable 'completion' plugin in ZSH echo "source $HOME/.zsh/completion.zsh" >> ~/.zshrc |
这次要在~/.zshrc文件中多加几行:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# rest of the `~/.zshrc` file # Load completion config source $HOME/.zsh/completion.zsh # Initialize the completion system autoload -Uz compinit # Cache completion if nothing changed - faster startup time typeset -i updated_at=$(date +'%j' -r ~/.zcompdump 2>/dev/null || stat -f '%Sm' -t '%j' ~/.zcompdump 2>/dev/null) if [ $(date +'%j') != $updated_at ]; then compinit -i else compinit -C -i fi # Enhanced form of menu completion called `menu selection' zmodload -i zsh/complist |
重启命令行工具,现在命令候选也有了:
你可能会问,为什么我不直接用Oh My Zsh呢?个人感觉,Oh My Zsh有点负担过于沉重了。我比较倾向于对自己所使用的工具有点掌控能力,我选择一步一步从零开始开始搭建一个庞然大物。
2.2.4 自动提示(Auto Suggestions)
在上面的候选项功能基础上,有自动提示功能就更好了。有了自动提示,只要用户一开始键入命令就会显示你可能想要的内容,试试 GitHub - zsh-users/zsh-autosuggestions: Fish-like autosuggestions for zsh。
安装:
1 2 3 4 5 6 7 8 9 10 |
# Download 'zsh-autosuggestions' plugin cd ~/.zsh && git clone git@github.com:zsh-users/zsh-autosuggestions.git # Enable 'zsh-autosuggestions' plugin in ZSH echo "source $HOME/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh" >> ~/.zshrc # Reload ZSH source ~/.zshrc |
这个插件真的在自动提示方面干得非常出色,你可以按方向键来接受来自系统的提示。
2.2.5 命令历史的设置
现在我们要用一个Oh My Zsh上已经准备好的设置文件,来设置我们的命令历史。
1 2 3 4 5 6 7 8 |
# Download history config cd ~/.zsh && wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/lib/history.zsh # Enable 'history' config in ZSH echo "source $HOME/.zsh/history.zsh" >> ~/.zshrc # Reload ZSH source ~/.zshrc |
现在,按方向键的上下键,你可以跳到上一次输入的命令。
你甚至可以使用Control + R来搜索输入过的命令。
2.2.6 给ls的结果着色
现在如果我们想列出文件夹中的内容,是一个灰色的列表:
看上去不太妙啊,或许加点颜色让他更可读比较好。
在使用ls命令的时候,有个-G选项。
1 2 3 |
-G Enable colorized output. This option is equivalent to defining CLICOLOR in the environment. (See below.) |
但是,每次都加上-G可就太累了,于是我们创建一个别名(Alias):
1 2 3 4 5 6 7 |
# Enable colorized output for `ls` command. echo "alias ls='ls -G'" >> ~/.zshrc # Reload ZSH source ~/.zshrc |
2.2.7 快捷键
既然每天都要用命令行工具,那么快捷键就是必要的。使用按键跳转光标到一行的开始(CMD + ←),或者跳转光标到一行的结束(CMD + →)。
安装快捷键绑定:
1 2 3 4 5 6 7 8 9 10 |
# Download key bindings config cd ~/.zsh && wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/lib/key-bindings.zsh # Enable 'key-bindings' config in ZSH echo "source $HOME/.zsh/key-bindings.zsh" >> ~/.zshrc # Reload ZSH source ~/.zshrc |
2.2.8 别名(Aliases)
在使用命令行工具的时候,别名很有用处。你可以预先定义一些快捷命令,在你开发APP或者编写脚本的时候确实地提升你的效率。
1 2 3 4 |
touch aliases.zsh echo "source $HOME/.zsh/aliases.zsh" >> ~/.zshrc |
下面罗列出了一些我经常用的别名:
~/.zsh/aliases.zsh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
alias ls='ls -G' # colorize `ls` output alias zshreload='source ~/.zshrc' # reload ZSH alias shtop='sudo htop' # run `htop` with root rights alias grep='grep --color=auto' # colorize `grep` output alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' alias less='less -R' alias g='git' alias rm='rm -i' # confirm removal alias cp='cp -i' # confirm copy alias mv='mv -i' # confirm move alias cal='gcal --starting-day=1' # print simple calendar for current month alias weather='curl v2.wttr.in' # print weather for current location (https://github.com/chubin/wttr.in) |
还有一些小小的福利,这里有一些git的别名可以帮助你。下面的命令很宽泛,但是我写了一些注释来帮助你理解这些命令是做什么的。
~/.gitconfig
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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
[alias] a = add # Add file contents to the index ai = add --interactive # Add modified contents in the working tree interactively to the index. ############## b = branch ba = branch --all # List both remote-tracking branches and local branches. bav = branch --all --verbose # When in list mode, show sha1 and commit subject line for each head, along with relationship to upstream branch (if any) bd = branch --delete # Delete a branch. The branch must be fully merged in its upstream branch, or in HEAD if no upstream was set with --track or --set-upstream-to. bdd = branch -D # Shortcut for --delete --force. bm = branch --move # Move/rename a branch and the corresponding reflog. bmm = branch -M # Shortcut for --move --force. br = branch --remotes # List or delete (if used with -d) the remote-tracking branches. ############## c = commit # Record changes to the repository ca = commit --all # Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected. cm = commit -m # Use the given as the commit message. cam = commit -am # Shortcut for --all and -m cem = commit --allow-empty -m # Allows to create a commit without any files modified cd = commit --amend # Replace the tip of the current branch by creating a new commit. cad = commit --all --amend # Shortcut for --amend and --all cadne = commit --all --amend --no-edit # Amends a commit without changing its commit message. ############## cl = clone # Clone a repository into a new directory cld = clone --depth 1 # Create a shallow clone with a history truncated to the specified number of commits. ############## cp = cherry-pick # Apply the changes introduced by some existing commits cpa = cherry-pick --abort # Cancel the operation and return to the pre-sequence state. cpc = cherry-pick --continue # Continue the operation in progress using the information in .git/sequencer. Can be used to continue after resolving conflicts in a failed cherry-pick or revert. cps = cherry-pick --skip # Skip the current commit and continue with the rest of the sequence. ############## d = diff # Show changes between commits, commit and working tree, etc di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d" # `git di $number` shows the diff between the state `$number` revisions ago and the current state dt = difftool # Show changes using common diff tools ############## f = fetch # Download objects and refs from another repository fo = fetch origin # Update the remote-tracking branches fu = fetch upstream # Fetch the branches and their respective commits from the upstream repository. ############## fk = fsck # Verifies the connectivity and validity of the objects in the database ############## g = grep -p # Print lines matching a pattern ############## l = log --oneline # Show commit logs, the commit message is prefixed with this information on the same line. lg = log --oneline --graph --decorate # Draw a text-based graphical representation of the commit history on the left hand side of the output. lgs = !"git log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short" # SHA + date + Commit message + author lgc = !"git log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat" # SHA + Commit message + author + changed files lgt = !"git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all" # As tree: SHA + Commit message + Time ago + author ############## ls = ls-files # Show information about files in the index and the working tree lsm = ls-files --modified # Show modified files in the output lss = ls-files --stage # Show staged contents' mode bits, object name and stage number in the output. ############## m = merge # Join two or more development histories together ma = merge --abort # Abort the current conflict resolution process, and try to reconstruct the pre-merge state. mc = merge --continue # After a git merge stops due to conflicts you can conclude the merge by running git merge --continue mq = merge --quit # Forget about the current merge in progress. Leave the index and the working tree as-is. mm = merge master # Merge 'master' branch to the current branch. ############## o = checkout # Switch branches or restore working tree files. om = checkout master # Switch branch to master. ob = checkout -b # Create and switch to a new branch ############## pr = prune --verbose --progress # Prune all unreachable objects from the object database. Report all removed objects. Show progress. prn = prune --dry-run # Do not remove anything; just report what it would remove. ############## ps = push # Update remote refs along with associated objects psa = push --all # Push all branches (i.e. refs under refs/heads/); cannot be used with other . psf = push --force # Usually, the command refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it. This flag disables these checks, and can cause the remote repository to lose commits; use it with care. psu = push --set-upstream # For every branch that is up to date or successfully pushed, add upstream (tracking) reference. ############## pso = push origin # `origin` is an alias in the system for a particular remote repository. Can be checked by running `git remote -v`. psao = push --all origin # Same as `push --all` but for origin. psfo = push --force origin # Same as `push --force` but for origin. psuo = push --set-upstream origin # Same as `push --set-upstream` but for origin. ############# psom = push origin master # Same as `push origin` but for master branch. psaom = push --all origin master # Same as `push --all origin` but for master branch. psfom = push --force origin master # Same as `push --force origin` but for master branch. psuom = push --set-upstream origin master # Same as `push --set-upstream origin` but for master branch. ############# pl = pull # Fetch from and integrate with another repository or a local branch. plr = pull --rebase # When true, rebase the current branch on top of the upstream branch after fetching. plv = pull --verbose # Pass --verbose to git-fetch and git-merge. ############# plo = pull origin # Same as `pull` but for origin. plro = pull --rebase origin # Same as `pull --rebase` but for origin. plom = pull origin master # Same as `pull origin` but for master branch. ############# plu = pull upstream # Same as `pull` but for upstream. plum = pull upstream master # Same as `pull upstream` but for master branch. plrum = pull --rebase upstream master # Same as `pull --rebase` but for upstream and master branch. ############# rb = rebase # Reapply commits on top of another base tip. rba = rebase --abort # Abort the rebase operation and reset HEAD to the original branch. rbc = rebase --continue # Restart the rebasing process after having resolved a merge conflict. rbi = rebase --interactive # Make a list of the commits which are about to be rebased. Let the user edit that list before rebasing. This mode can also be used to split commits. rbs = rebase --skip # Restart the rebasing process by skipping the current patch. rbin = "!r() { git rebase -i HEAD~$1; }; r" # Interactive rebase with the given number of latest commits. ############# re = reset # Reset current HEAD to the specified state rh = reset HEAD # HEAD is defined explicitly reh = reset --hard # Resets the index and working tree. Any changes to tracked files in the working tree since are discarded. rem = reset --mixed # Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated. This is the default action. res = reset --soft # Does not touch the index file or the working tree at all (but resets the head to , just like all modes do). This leaves all your changed files "Changes to be committed". rehh = reset --hard HEAD # HEAD is defined explicitly remh = reset --mixed HEAD # HEAD is defined explicitly resh = reset --soft HEAD # HEAD is defined explicitly rehom = reset --hard origin/master # Throw away all my staged and unstaged changes, forget everything on my current local branch and make it exactly the same as origin/master. ############# r = remote # Manage set of tracked repositories ra = remote add # Adds a remote named for the repository at . rr = remote remove # Remove the remote named . All remote-tracking branches and configuration settings for the remote are removed. rv = remote --verbose # Be a little more verbose and show remote url after name. rn = remote rename # Rename the remote named to . All remote-tracking branches and configuration settings for the remote are updated. rp = remote prune # Deletes stale references associated with . By default, stale remote-tracking branches under are deleted, but depending on global configuration and the configuration of the remote we might even prune local tags that haven't been pushed there. rs = remote show # Gives some information about the remote . rao = remote add origin # Add new origin. rau = remote add upstream # Add new upstream. rro = remote remove origin # Remove origin. rru = remote remove upstream # Remove upstream. rso = remote show origin # Show current origin. rsu = remote show upstream # Show current upstream. rpo = remote prune origin # Prune current origin. rpu = remote prune upstream # Prune current upstream. ############# rmf = rm -f # Remove files from the working tree and from the index. Override the up-to-date check. rmrf = rm -r -f # Same as above + Allow recursive removal when a leading directory name is given. ############# s = status # Show the working tree status sb = status -s -b # Same as above + Give the output in the short-format. Show the branch and tracking info even in short-format. ############# sa = stash apply # Like pop, but do not remove the state from the stash list. sc = stash clear # Remove all the stash entries. Note that those entries will then be subject to pruning, and may be impossible to recover. sd = stash drop # Remove a single stash entry from the list of stash entries. When no is given, it removes the latest one. sl = stash list # List the stash entries that you currently have. sp = stash pop # Remove a single stashed state from the stash list and apply it on top of the current working tree state, i.e., do the inverse operation of git stash push. sps = stash push # Save your local modifications to a new stash entry and roll them back to HEAD (in the working tree and in the index). The part is optional and gives the description along with the stashed state. spsk = stash push -k # All changes already added to the index are left intact. sw = stash show # Show the changes recorded in the stash entry as a diff between the stashed contents and the commit back when the stash entry was first created. When no is given, it shows the latest one. st = !git stash list | wc -l 2>/dev/null | grep -oEi '[0-9][0-9]*' ############# t = tag # Create, list, delete or verify a tag object signed with GPG. td = tag --delete # Delete existing tags with the given names. tl = tag --list # Show verbose output about tags. ############# w = show # Show various types of objects. wo = show --oneline # This is a shorthand for "--pretty=oneline --abbrev-commit" used together. wf = show --format=fuller # Print more extensive info. ############# aliases = !git config -l | grep alias | cut -c 7- # List git aliases branches = branch --all # List both remote-tracking branches and local branches. remotes = remote --verbose # Be a little more verbose and show remote url after name. contributors = shortlog --summary --numbered # List contributors with number of commits amend = commit --amend --no-edit # Amend the currently staged files to the latest commit. go = "!f() { git checkout -b \"$1\" 2>/dev/null || git checkout \"$1\"; }; f" # Switch to a branch, creating it if necessary fb = "!f() { git branch -a --contains $1; }; f" # Find branches containing commit ft = "!f() { git describe --always --contains $1; }; f" # Find tags containing commit fc = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short -S$1; }; f" # Find commits by source code fm = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short --grep=$1; }; f" # Find commits by commit message dm = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d" # Remove branches that have already been merged with master (a.k.a. ‘delete merged’) |
总结
我希望这篇文章能帮助你提升你的命令行工具使用效率(最好是爆炸性的!)。以上也只是一个入门或者初级的,而非最终形态的解决方案。还有数不清的工具,插件和设置等待着你去发掘。每个使用者都有自己不同的环境,不同的技术。
我尽量把注意力放在了许多使用者都会用到的一些功能上面。
如果你也有一些非常棒的迫不及待想要介绍给大家的工具,欢迎留下你的评论。
评论