Linux命令行加強版

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行

 

參考資料:https://zhuanlan.zhihu.com/p/48076652

本文地址:  http://www.javashuo.com/article/p-crlxsizs-my.html

相關文章
相關標籤/搜索