DEV Community

Zander Martineau
Zander Martineau

Posted on • Originally published at

My command line reference

A mixture of my favourite CLI tools and things that I usually forget

Disclaimer: If you don't use fish-shell, some of the packages might not work. There will be alternatives for each of them for your own shell.

Keyboard shortcuts


Search previously used commands


Invoke FZF fuzzy file finder (see below)


Clear the terminal screen


Clears the terminal screen but no-scroll back. Basically wipes the


Cut one word backwards using white space as delimiter


Swap the last two words before the cursor



Show a calendar

❯ cal  
   September 2019  
Su Mo Tu We Th Fr Sa  
 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


Show the date

Sat  7 Sep 2019 09:22:28 BST


Show directory contents as a tree

❯ tree -L 1  
├── components  
├── designsystem  
├── layouts  
├── next.config.js  
├── node_modules  
├── now.json  
├── package.json  
├── pages  
├── redirects.js  
├── scripts  
├── server.js  
├── static  
├── utils  
└── yarn.lock

List global packages

# with yarn  
❯ yarn global list  
yarn global v1.17.3  
info "canvas-sketch-cli@1.4.2" has binaries:  
   - canvas-sketch  
   - canvas-sketch-cli  
   - canvas-sketch-gif  
   - canvas-sketch-mp4  
info "create-react-app@2.1.2" has binaries:  
   - create-react-app  
info "docusaurus-init@1.0.1" has binaries:  
   - docusaurus-init  
info "emma-cli@2.0.1" has binaries:  
   - emma  
   - ema  
info "emoj@2.0.0" has binaries:  
   - emoj  
info "fx@10.0.0" has binaries:  
   - fx  
info "ibrew@1.1.1" has binaries:  
   - ibrew  
info "jscodeshift@0.6.2" has binaries:  
   - jscodeshift  
info "lighthouse@5.0.0" has binaries:  
   - lighthouse  
   - chrome-debug  
info "majestic@1.2.24" has binaries:  
   - majestic  
info "np@4.0.2" has binaries:  
   - np  
info "npm@6.0.0" has binaries:  
   - npm  
   - npx  
info "parcel-bundler@1.9.2" has binaries:  
   - parcel  
info "plop@2.1.0" has binaries:  
   - plop  
info "prettier@0.22.0" has binaries:  
   - prettier  
info "release-it@12.3.5" has binaries:  
   - release-it  
info "rimraf@2.6.3" has binaries:  
   - rimraf  
info "semver@5.6.0" has binaries:  
   - semver  
info "serve@10.0.2" has binaries:  
   - serve  
info "strapi@3.0.0-alpha.13.0.1" has binaries:  
   - strapi  
info "terser@3.8.2" has binaries:  
   - terser  
info "types-installer@1.4.0" has binaries:  
   - types-installer  
info "yalc@1.0.0-pre.27" has binaries:  
   - yalc  
✨  Done in 5.61s.  

# with npm  
❯ npm -g ls --depth=0

Custom packages


autojump is a faster way to navigate your filesystem. It works by maintaining a database of the directories you use the most from the command line.

❯ j code


A modern version of ls

❯ exa -l  
❯ exa -T -L 2 # like tree


Fuzzy find files. Use ctrl+t to access it


Static file serving and directory listing


Search for npm packages. Run emma to initialise the search, then enter your search criteria


Interactive search CLI for Homebrew

Run ibrew to initialise the search, then enter your search criteria


Work with yarn/npm packages locally like a boss.


# clone one of your GitHub repos  
❯ hub clone dotfiles  
# Same as → git clone git://  

# clone another project's repo  
❯ hub clone github/hub  
# → git clone git://  

# open the current project's issues page  
❯ hub browse -- issues  
# → open  

# open another project's wiki  
❯ hub browse mojombo/jekyll wiki

List the current repo's PRs

# this is an alias  
alias prs 'hub pr list -L 20 -b develop --format="%t%n - Branch: [%H]%n - %U%n - %l%n%n"'  
# e.g. ❯ prs

Create a branch and switch to it

# FYI This is a fish shell function  
function branch  
   git branch {$argv} && git checkout {$argv}  
# e.g. ❯ branch feature/WL-88-hello


Shows a list of commits for the past 24 hours

❯ standup  
5315f033 - build(multi): HM-925 Improve perf for a couple of pages (16 hours ago) <Zander Martineau>  
4b41c048 - index on feature/HM-925-improve-performance: 1b854d84 fix(ci): AWS-99 Remove builds/deployments associated (#845) (17 hours ago) <Zander Martineau>


Kill a process running on a particular port

❯ kill-port 9001


Generated markdown table of contents

❯ doctoc --github


Command-line JSON processing tool

❯ fx package.json


jq is like sed for JSON data - you can use it to slice and filter and map and transform structured data with the same ease that sed, awk, grep and friends let you play with text.

# use jq to extract just the first commit from a repos list  
❯ curl '' | jq '.[0]'


Safely* install packages with npm or yarn by auditing them as part of your install process

# with npm   
❯ npq install express   

# with yarn, set an alias like so:  
alias npq="NPQ_PKG_MGR=yarn npq-hero"  
❯ npq add express


# install  
brew install youtube-dl  

# use  
❯ youtube-dl d2qfa3tlgH8

Are there any that I've missed? Let me know in the comments

Top comments (0)