134 aliases,
8 git aliases,
9 functions
last updated: 2022-11-09T09:09:18+00:00
This page holds a collection of shell aliases and functions I use regularly. I will soon write a sync script to automatically update my alias collection on every computer I use to turn this into an over-engineered alias management system.
This is generated using jinja2 from a YAML file of mine. Note that some aliases might have a strange escaping because I escape them using Python's shlex module.
Rather basic aliases that you might already have built into your shell.
Why isn't this the default?!
alias chmod='chmod --preserve-root'
Why isn't this the default?!
alias chown='chown --preserve-root'
alias hd='hexdump -C'
alias ka=killall
alias l='ls -lah'
alias la='ls -lAh'
alias ll='ls -lh'
alias md=mkdir
alias mdp='mkdir -p'
alias rd=rmdir
Docker-related shortcuts.
alias dccp='docker container cp'
alias dco=docker-compose
alias dcp='docker container prune'
alias dcpf='docker container prune -f'
alias de='docker exec'
alias dei='docker exec -it'
alias di='docker inspect'
alias dip='docker image prune'
alias dipf='docker image prune -f'
alias dk='docker kill'
alias dka='docker ps -q | xargs docker kill'
alias dl='docker logs'
alias dlf='docker logs -f'
alias dlft='docker logs -f --tail'
alias dlt='docker logs --tail'
alias dn='docker network'
alias dnc='docker network create'
alias dnp='docker network prune'
alias dnpf='docker network prune -f'
alias dp='docker ps'
alias dpq='docker ps -q'
alias dr='docker run'
alias dri='docker run -it'
alias drmi='docker rmi'
alias drmia='docker images -q | xargs docker rmi'
alias dsp='docker system prune'
alias dspf='docker system prune -f'
Aliases of questionable usefulness, mostly for puns, private jokes, or showing off.
For when I get confused between Vim and a shell.
alias :q=exit
alias ':q!'=exit
alias :wq=exit
In honour of ~aliasless!
alias aliasless='alias | less'
A common spelling I have seen on the fediverse.
git config --global alias.cofe coffee
git config --global alias.coffee '!curl -L https://git.io/coffee'
Thanks, Trump.
git config --global alias.covfefe coffee
For the big bad moo-ds.
alias cowanxiety='figlet -f big -w 999999 | cowthink -nw'
For the big moo-ds.
alias cowscream='figlet -f big -w 999999 | cowsay -nw'
Convert normal character to their full-width equivalents. Great for vaporware-style text, or for messing up some terminals.
alias fullwidth='sed "y/!\"#\$%&'"'"'()*+,-.\/0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~¢£¬¯¦¥ /!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~¢£¬ ̄¦¥ /"'
Mac- and Linux-compatible.
git config --global alias.gud '!xdg-open http://lmgtfy.com/\?s\=d\&iie\=1\&q\=how+to+use+git 2>/dev/null || open http://lmgtfy.com/\?s\=d\&iie\=1\&q\=how+to+use+git'
git config --global alias.joke '!curl -s https://raw.githubusercontent.com/EugeneKay/git-jokes/lulz/Jokes.txt | shuf | head -n1'
alias nuke='kill -9'
For when you want to be polite with your terminal.
alias please=sudo
French pun: the french noun «poule» (chicken) is pronounced in the same way as the english verb "pull".
git config --global alias.poule pull
alias scream='tr '"'"'[[:lower:]]'"'"' '"'"'[[:upper:]]'"'"''
I like trains, but not too much.
alias sl='sl -e'
alias whisper='tr '"'"'[[:upper:]]'"'"' '"'"'[[:lower:]]'"'"''
Git-related shortcuts.
alias ga='git add'
alias gaa='git add -A'
alias gapa='git add --patch'
alias gb='git branch'
alias gbd='git branch -d'
alias gbD='git branch -D'
1 | function gbdo () { |
alias gbs='git bisect'
alias 'gbs!'='git bisect start'
alias gbsb='git bisect bad'
alias gbsg='git bisect good'
alias gbsr='git bisect reset'
alias gbss='git bisect skip'
alias gc='git commit'
alias gca='git commit -a'
alias gcaan='git commit --amend -a --no-edit'
alias gcaans='git commit --amend -a -s --no-edit'
alias gcam='git commit -a -m'
alias gcams='git commit -a -s -m'
alias gcan='git commit --amend --no-edit'
alias gcans='git commit --amend -s --no-edit'
alias gcas='git commit -a -s'
alias gch='git checkout'
alias gchb='git checkout -b'
alias gchm='git checkout master'
alias gcm='git commit -m'
alias gcms='git commit -s -m'
alias gcp='git cherry-pick'
alias gcpa='git cherry-pick --abort'
alias gcpc='git cherry-pick --continue'
alias gcs='git commit -s'
alias gd='git diff'
alias gds='git diff --staged'
alias gf='git fetch'
alias gfp='git fetch --prune'
For when you give up with command-line Git.
alias gg='git gui'
Yet another git log alias. You will probably want to customize it with your own format.
alias gl='git log --graph --pretty=format:'"'"'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"'"' --abbrev-commit --all'
alias gm='git merge'
alias gma='git merge --abort'
For when you type your aliases so fast you miss a key.
alias got=git
alias gp='git push'
alias gpf='git push --force-with-lease'
alias gpfo='git push --force-with-lease origin'
Git push with options for automatically creating a GitLab merge request with a given title.
1 | function gpmr () { |
alias gpu='git push -u origin'
alias gr='git remote'
alias gra='git remote add'
alias grb='git rebase'
alias grba='git rebase --abort'
alias grbc='git rebase --continue'
alias grbi='git rebase -i'
alias grbm='git rebase master'
alias grbs='git rebase --skip'
alias grh='git reset'
alias grhh='git reset --hard'
alias grl='git reflog'
alias grmv='git remote rename'
alias grpo='git remote prune origin'
alias grrm='git remote remove'
alias gs='git status'
alias gst='git stash'
alias gsta='git stash push'
alias gstam='git stash push -m'
alias gstd='git stash clear'
alias gstl='git stash list'
alias gstp='git stash pop'
alias gsts='git stash show --text'
alias gt='git tag'
alias gtd='git tag -d'
alias gtf='git tag -f'
You can also have a function that looks for 'status' in the argument, and prints 'hungry' for gut status
.
alias gut=git
Word diffs can be quite useful when reviewing changes on repos full of text, and not code!
git config --global alias.wdiff 'diff --word-diff'
Just like my git wdiff
alias, but for git show
.
git config --global alias.wshow 'show --word-diff'
Python-related shortcuts.
Yet another fat finger autocorrector, but for Django.
alias ./maange.py=./manage.py
alias ./maange.Py=./manage.py
alias cdp=cdproject
Using virtualenvwrapper's mktmpenv
, then not deactivating properly, results in useless environments piling up!
alias prunetmpenv='rmvirtualenv $(wk | grep ^tmp-)'
alias wk=workon
Aliases that are quite specific to my own setup.
Clear all of the local Redis database!
alias flushall='echo FLUSHALL | redis-cli'
Named after a private joke at work. Cleans up your swap.
Be careful not to run this if you do not have enough space in RAM or if you still have some programs eating up your RAM: this could freeze your machine.
alias nuketheswap='sudo swapoff -a; sudo swapon -a'
I have KDEConnect installed on my OnePlus One, and I often use its not-so-comfortable CLI.
alias oneplus='kdeconnect-cli -n '"'"'OnePlus One'"'"''
As an i3 user, the easiest way for me to shut the computer down is to
use shutdown now
. I can use i3's launcher to do that, or I can just
run that in any terminal that I already have opened. As I often leave an
SSH connection to tilde.town opened for a while when my home computer is
running, sometimes I accidentally try to shut the town down!
Luckily, it does not let me do that because there are other users logged on, but I set an alias just to avoid the little scare I can get from that.
alias shutdown=exit
Used in my Termux setup because the ssh-agent compatible ssh is ssha.
alias ssh=ssha
An alias for HTTPie to use HTTPS more quickly
alias https='http --default-scheme=https'
Stolen from some reply on StackExchange.
1 | function mkcd () { |
alias moon='curl --fail -s "https://wttr.in/moon"'
1 | function oxo () { |
1 | function shorten () { |
alias sqlite=sqlite3
Lets you use Google Translate right from your terminal! I initially wrote this because I was writing some wiki pages over SSH from a Windows XP laptop, which definitely was not happy with opening a web browser and loading all of Google Translate each time I was confused about a word.
1 | function translate () { |
1 | function ttm () { |
1 | function ttmu () { |
Because I always forget how to extract .tar.zst archives.
alias unzst='tar -I zstd -xf'
alias weather='curl --fail -s "https://wttr.in/?format=v2"'
alias ytdl=youtube-dl
I mostly only ever use youtube-dl to fill my music library. You can use this as ytmp3 dQw4w9WgXcQ
to use the video's original title, or ytmp3 dQw4w9WgXcQ "We Are Number One"
to use your own.
1 | function ytmp3 () { |