0. 前言html
周末大早上的,没事作,了解下这几个命令了,哎~~~。node
正常状况下,Linux下的命令行,界面比较丑,命令行命令有时候也不是很友好,下面就经过这几个命令或工具,美化一下命令行。git
1. oh-my-zshgithub
这个就没有什么能够讲的了,直接从github上clone下来,安装github上的readme文档进行安装。https://github.com/robbyrussell/oh-my-zsh数据库
2. cat 命令npm
可使用bat命令,代替默认的cat命令,打印文本内容,能够进行高亮显示,比较好用。github地址:https://github.com/sharkdp/bat
我是在debian系统,直接在 https://github.com/sharkdp/bat/releases 下载,而后dpkg -i *.deb 便可
在 ~/.zshrc 加上 alias cat = 'bat'缓存
3. ping 命令curl
可使用prettyping 命令来代替ping命令。这个prettyping命令,看名字就知道,比默认的ping 命令会好看不少。哈哈。工具
1 curl -O https://raw.githubusercontent.com/denilsonsa/prettyping/master/prettyping 2 chmod +x prettyping 3 mv prettyping /usr/local/bin/
在 ~/.zshrc alias ping = 'prettyping'性能
4. autojump 命令
用于快速切换历史进入过的目录
apt-get install autojump
而后在 ~/.zshrc 中的 plugins 增长 autojump, 之后就能够经过 j 命令 tab tab 快速切换目录,不过这个好像没有下面要介绍的这个好用。
5. ctrl+r命令
在终端里,使用fzf命令代替ctrl+r命令反向搜索。具体安装参考 https://github.com/junegunn/fzf
1 git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf 2 ~/.fzf/install 3 source ~/.zshrc
使用方法
COMMAND [DIR]/**<TAB>
kill -9 <TAB>
扩展一个预览的功能,在 ~/.zshrc 中增长
alias preview="fzf --preview 'bat --color \"always\" {}"
6. top命令
这个就是美化top命令,经过 apt-get install htop
7. diff 命令
能够经过 diff-so-fancy 命令来代替默认的diff命令,来对比两个文件。 参考 https://github.com/so-fancy/diff-so-fancy
8. find 命令
使用fd命令来代替find命令,默认的find命令性能比较差,没有创建数据库及缓存,每次都是读取磁盘文件。https://github.com/sharkdp/fd/ 直接在 https://github.com/sharkdp/fd/releases 下载 deb包安装
fd -e zip -x unzip
fd [模糊文件名] [-e 后缀] [-x 找到后执行命令]
9. du 命令
有时候咱们须要用du查看当前文件的磁盘占用。并以友好界面展示。
apt-get install ncdu
alias du="ncdu --color dark -rr -x --exclude .git --exclude node_modules"
10. man 命令
平时咱们遇到不会的命令,都会用到man查一下文档(实际上是百度一下啦),而每每咱们只是忘记了这个命令须要加什么参数。不须要了解太多的文档的内容和技术细节,这个时候就有一个工具 tldr工具。 TL;DR Too Long; Didn't Read
有不少种安装方式,应该比较符合大众的就是 pip 或 npm 方式了。
1 pip install tldr 2 pip install tldr.py 3 npm install -g tldr 4 alias help='tldr'
11. grep 命令
常常用grep进行文本内容过滤,平时的命令组合 netstat -anop | grep 8080 之类的,就没有太大关系,可是若是是多文件目录,须要查找目录下,哪一个文件包含了某些内容,只用grep就有点麻烦了,这个时候可使用 ack 命令。
1 apt-get install ack-grep 2 ack foo --js -A 2 -B 2 #在当前目录下,查找js文件中包含foo文本,并打印与其相关的上下2行