Skip to content

All useful CLI commands in one place

Notifications You must be signed in to change notification settings

ikim23/cli-cheatsheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

CLI Cheatsheet

Homebrew

Command
brew search <text|/text/>
brew install <formula>
brew install --cask <cask>
brew uninstall <formula>
brew list
brew upgrade <outdated_formula>
brew update && brew upgrade `brew outdated`
brew analytics off

Chocolatey

Command
choco search <filter>
choco install <pkg> [<pkg2> [<pkgN>]]
choco uninstall <pkg|all> [pkg2 [pkgN]]
choco list -lo
choco upgrade all
choco upgrade all --except="<pkg[,pkg2]>"

Git

Create git alias:

git config --global alias.gone "! git fetch -p && git for-each-ref --format '%(refname:short) %(upstream:track)' | awk '\$2 == \"[gone]\" {print \$1}' | xargs -r git branch -D"

alias gpha="git push && git rev-parse HEAD | tr -d '\n' | pbcopy"
Zsh Alias Command
gst git status
glo git log --oneline --decorate
glol git log --graph --pretty='...'
gl git pull
gp git push
gpf git push --force-with-lease
gpsup git push --set-upstream origin $(git_current_branch)
gco git checkout
gco - checkout to previous branch
gcm git checkout $(git_main_branch)
gc git commit -v
gc! git commit -v --amend
gmom git merge origin/$(git_main_branch)
gstl git stash list
gsta git stash push
gstp git stash pop
gstaa git stash apply
gstd git stash drop
gpristine git reset --hard && git clean -dffx
grhh git reset --hard
grb git rebase
grba git rebase --abort
grbc git rebase --continue
grbm git rebase $(git_main_branch)
grbd git rebase develop
grbi HEAD~3 git rebase -i HEAD~3
git tag <tag-name>
git push origin <tag-name>
git tag -d <tag-name>
git push --delete origin <tag-name>

Markdown

Markdown Example
*italics* or _italics_ italics or italics
**bold** or __bold__ bold or bold
**_bold italics_** bold italics
~~strikethrough~~ strikethrough
> blockquote

NVM

Command
nvm use
nvm use --lts
nvm alias default 14
nvm ls
nvm ls-remote | grep -i "<node_version>"
nvm install <node_version>
nvm install --lts
nvm uninstall <node_version>

Docker

Command Description
docker ps list containers
docker ps -a list all containers
docker ps -aq list all container ids
docker images list downloaded images
docker cp <container_id>:<src_path> <dst_path> copy from container to local machine
docker cp <src_path> <container_id>:<dst_path> copy from local machine to container
docker rm remove container
docker rm $(docker ps -aq) remove all containers
docker rmi [-f] <image> remove image
docker stop <container_id>
docker exec -it <container_id> <command> run CLI command inside the container
docker-compose up -d builds, (re)creates, starts, and attaches to containers for a service
docker version
docker-compose version

PostgreSQL

Command Description
psql -h <hostname> -p <port> -U <username> -d <dbname> -W connect to database (-W option means propmt password)
\h help
\q quit
\l list databases
\c <dbname> connect to database
\dt display tables
\du display user roles

Knex

Command Description
knex init create new knex file
knex migrate:make migration_name create migration file
knex migrate:latest run all migration that has not yet been run
knex migrate:rollback rollback the last batch of migrations
knex migrate:rollback --all rollback all the completed migrations
knex migrate:up run the next migration that has not yet been run
knex migrate:down undo the last migration that was run
knex migrate:list list both completed and pending migrations

Linux

Command Description
Ctrl + U Terminal: delete whole command
Ctrl + K Terminal: delete right of the cursor
Ctrl + W Terminal: delete word
ln -s <target_file> <link_name> create symbolic link

About

All useful CLI commands in one place

Topics

Resources

Stars

Watchers

Forks