作为程序员都习惯在命令行下操作,今天就推荐些命令行神器,可能会让你大开眼界。

统计当前目录下有多少行代码 line-counter

  1.  
//https://github.com/MorganZhang100/line-counter

//find . -name '*.py' -exec wc -l {} +

//wc -l

pip install line-counter  

$ line

Search in /Users/Morgan/Documents/Example/

file count: 4

line count: 839

$ line -d

Search in /Users/Morgan/Documents/Example/

Dir A/file C.c                                             72

Dir A/file D.py                                           268

file A.py                                                 467

file B.c                                                   32

file count: 4

line count: 839

//https://github.com/AlDanial/cloc

npm install -g cloc  

$ cloc wechat-cli.py

      1 text file.

      1 unique file.

      0 files ignored.

github.com/AlDanial/cloc v 1.72  T=0.14 s (7.4 files/s, 779.4 lines/s)

-------------------------------------------------------------------------------

Language                     files          blank        comment           code

-------------------------------------------------------------------------------

Python                           1             12              7             87

-------------------------------------------------------------------------------


命令行纠错 thefuck

  1.  
//https://github.com/nvbn/thefuck

pip install thefuck

➜ apt-get install vim

E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)

E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

➜ fuck

sudo apt-get install vim

[sudo] password for nvbn:

Reading package lists... Done


mysql 客户端,支持语法高亮和命令补全 mycli

  1.  
// https://github.com/dbcli/mycli

pip install -U mycli

$ mycli -h localhost -uroot

Password:

Version: 1.8.0

Chat: https://gitter.im/dbcli/mycli

Mail: https://groups.google.com/forum/#!forum/mycli-users

Home: http://mycli.net

Thanks to the contributor - Tech Blue Software

mysql root@localhost:(none)> use test

You are now connected to database "test" as user "root"

Time: 0.005s

mysql root@localhost:test> show t

                                 TABLE STATUS

                                 TABLE STATUS

                                 TABLES

                                 TABLES

                                 TRIGGERS

                                 TRIGGERS

                                 STATUS

[F2] Smart Completion: ON  [F3] Multiline: OFF  [F4] Emacs-mode


json文件处理以及格式化显示,支持高亮,可以替换python -m json.tool

  1.  
  2. //https://github.com/stedolan/jq http://blog.chinaunix.net/uid-24774106-id-3830242.html
    
    $ cat json_raw.txt
    
    {"name":"Google","location":{"street":"1600 Amphitheatre Parkway","city":"Mountain View","state":"California","country":"US"},"employees":[{"name":"Michael","division":"Engineering"},{"name":"Laura","division":"HR"},{"name":"Elise","division":"Marketing"}]}
    
    cat json_raw.txt | jq '.location.state'
    
       "California"
    
    echo '{"foo": 42, "bar": "less interesting data"}' | jq .nofoo
    
       null
    
    cat json_raw.txt | jq 'keys'
    
    [
    
     "employees",
    
     "location",
    
     "name"
    
    ]

shell脚本静态检查工具 shellcheck

  1.  
//https://github.com/koalaman/shellcheck

apt-get install shellcheck

shellcheck test.sh


多线程下载工具 axel

  1.  
//  axel.alioth.debian.org/

sudo apt-get install axel

axel -n 10 -a <url>

axel -n 20 http://centos.ustc.edu.cn/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso


进程监控工具htop

  1.  
// https://hisham.hm/htop/


命令行请求工具 httpie

  1.  
//https://httpie.org/ https://github.com/jakubroztocil/httpie

pip install --upgrade httpie

http PUT example.org X-API-Token:123 name=John

http -f POST example.org hello=World

http example.org/file > file

http httpbin.org/post  --  -name-starting-with-dash=foo -Unusual-Header:bar

POST /post HTTP/1.1

-Unusual-Header: bar

Content-Type: application/json

{

   "-name-starting-with-dash": "value"

}


命令行查看文档 tldr

  1.  
// https://github.com/tldr-pages/tldr

npm install -g tldr

$ tldr curl

Cache is out of date, you should run "tldr --update"

 curl

 Transfers data from or to a server.

 Supports most protocols including HTTP, FTP, POP.

 - Download a URL to a file:

   curl "URL" -o filename

 - Send form-encoded data:

   curl --data name=bob http://localhost/form

 - Send JSON data:

   curl -X POST -H "Content-Type: application/json" -d '{"name":"bob"}' http://

localhost/login

 - Specify an HTTP method:

   curl -X DELETE http://localhost/item/123

 - Head request:

   curl --head http://localhost

 - Include an extra header:

   curl -H "X-MyHeader: 123" http://localhost

 - Pass a user name and password for server authentication:

   curl -u myusername:mypassword http://localhost


命令行提示工具 cheat

  1.  
//https://github.com/chrisallenlane/cheat

pip install cheat

cheat tar

# To extract an uncompressed archive:

tar -xvf '/path/to/foo.tar'

# To extract a .gz archive:

tar -xzvf '/path/to/foo.tgz'

# To create a .gz archive:

tar -czvf '/path/to/foo.tgz' '/path/to/foo/'

# To extract a .bz2 archive:

tar -xjvf '/path/to/foo.tgz'

# To create a .bz2 archive:

tar -cjvf '/path/to/foo.tgz' '/path/to/foo/'


字符转换成艺术字体 figlet

  1.  
//http://www.figlet.org/

   #           #              #             #

##########      #######    ##########    ##########

   #    #     #     #         #    #         #

   #    #    # #   #          #    #         #

  #     #       ###          #     #        #

 #   # #       ##           #   # #        #

#     #      ##            #     #       ##


后台运行和管理进程 pm2 同python的supervisoerd

  1.  
//http://pm2.keymetrics.io/

npm install pm2 -g

pm2 list


在命令行实时监控 Nginx 的神器 ngxtop

  1.  
//https://linux.cn/article-3205-1.html

pip install ngxtop

ngxtop -n 20

ngxtop info


python代码格式规范化工具 yapf

  1. //https://github.com/google/yapf
    
    pip install yapf
    
    >>> from yapf.yapflib.yapf_api import FormatCode  # reformat a string of code
    
    >>> FormatCode("f ( a = 1, b = 2 )")
    
    'f(a=1, b=2)\n'

命令行下模糊搜索工具 fzf

  1.  
//https://github.com/junegunn/fzf

brew install fzf

find * -type f | fzf > selected


网易云音乐命令行版本 musicbox

  1.  
//https://github.com/darknessomi/musicbox

pip(3) install NetEase-MusicBox

$ git clone https://github.com/darknessomi/musicbox.git && cd musicbox

$ python(3) setup.py install


多线程下载工具 aria2

  1.  
//https://github.com/aria2/aria2

aria2c http://a/f.iso ftp://b/f.iso

aria2 下载百度云链接https://github.com/acgotaku/BaiduExporter


比 python -m SimpleHTTPServer 更好的 http 服务器 http-server

  1.  
//https://github.com/indexzero/http-server

npm install http-server -g

http-server 8888

alias hs="source ~/.bash_profile && http-server -a $(ifconfig en0 | grep 'inet ' | cut -d ' ' -f 2)"

浏览器打开http://localhost:8888


获取汉字拼音 pypinyin

  1.  
pip install pypinyin

$ pypinyin 有哪些命令行的软件堪称神器

yǒu něi xiē mìng lìng xíng de ruǎn jiàn kān chē


更多

  1. climate 小工具集 https://github.com/adtac/climate

  2. 命令行天气预报 curl http://wttr.in/beijing

  3. 下载磁力链接npm install -g t-get  https://github.com/jeffjose/tget

  4. 前端代码实时预览工具 https://github.com/thewinds/biu

  5. 百度云/百度网盘Python客户端 pip install bypy  https://github.com/houtianze/bypy

  6. zip文件密码破解Fcrackzip sudo apt-get install fcrackzip

  7. ffmpeg 视频拆帧,合并帧为视频,视频转gif,视频转码,分离音视频

  8. lynx一款linux下的web浏览器。可用于浏览纯文本网站

  9. 百度网盘命令行工具https://github.com/GangZhuo/BaiduPCS

  10. terminal 录屏软件  asciinema.org

  11. 用户友好的命令行 shell https://github.com/fish-shell/fish-shell

  12. https://github.com/aharris88/awesome-cli-apps

  13. https://github.com/jlevy/the-art-of-command-line

  14. github.com/alebcay/awesome-shell

  15. https://github.com/Idnan/bash-guide

  16. https://www.zhihu.com/question/59227720

  17. markdown 编辑器 http://md.barretlee.com/