Useful Aliases in bash


(Monkey Wrench) #1

Drop some useful aliases, and a one liner why you use it:

alias 7zadd='7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=64m -ms=on'
Compress with one of the best comp. algos out there + 7z format is platform agnostic.

alias nmcli='nmcli -p -a'
Give me pretty output and ask me if I forgot something.

alias chmod='chmod -c'
Inform me of the change.


Lets see…

# quick blog reading
alias www="lynx -dump"

# just looks better in git diff this way
alias less="less -S --tabs=4"

# die, Python 2, die!
alias python="echo 'Use bpython!' #"
alias python3="echo 'Use bpython!' #"
alias pip="echo 'Use pip3!' #"

# you know, my git log usually looks like: fix, fix, fix, ...
alias commitpush="git commit -am fix ; git push origin HEAD"


[TROLL] Such explicit message [/TROLL] Just kidding :wink:

Otherwise :

alias ne='emacs -nw'
alias reload='source ~/.bash_profile'
alias clean='rm -rf *~'

(Command-Line Ninja) #4

Mine are simple yet useful.

alias pc="packer-color --noconfirm"¬
alias ls="ls --color=auto -sh"¬
alias editterm="vim ~/.config/termite/config"¬
alias vpn="cd ~/Documents/VPN && sudo (do vpn stuff, cause OPSEC)"

That’s all I’m using right now. My ls alias is my favourite however.


sudo apt-get sl
alias ls='sl’
alias sl=‘ls’

(Ne0_) #6

alias ls='ls -l’
alias vim='nano’
alias emacs=‘nano’

(g3ntleman) #7

First post, I hope someone finds those usefull

Quick access

alias aliases="nano ~/.config/zsh/.aliases"
alias i3config="nano ~/.config/i3/config"

Typo helpers

alias l='ls -CF'
alias sl='P=(" " █ ░ ▒ ▓); while :; do printf "\e[$[RANDOM%LINES+1];$[RANDOM%COLUMNS+1]f${P[$RANDOM%5]}"; done'
alias cd..="cd .."
alias ..="cd .."

ls helpers

alias ls="ls --color=always --group-directories-first"
alias lsl="ls -Al --color=always --group-directories-first"
alias ll='ls -alF'
alias la='ls -A'
alias ls-size='ls -lah'


alias setclip='xclip -selection c'
alias getclip='xclip -selection clipboard -o'


alias pb="curl -sF "[email protected]${1:--}" -w "%{redirect_url}" '' -o /dev/stderr | setclip"
alias cpb="getclip | pb"
alias paste="curl -F [email protected]"
alias paste2="curl -F 'f:1=<-'"


alias chmod='chmod -c'
alias rw-='chmod 600'
alias rwx='chmod 700'
alias r--='chmod 644'
alias r-x='chmod 755'

(Command-Line Ninja) #8

Nice! I’ve actually found is nice for uploading. You can do most files infact.

(oaktree) #9

Here are my little bash shortcuts!

# a quicker G++
g++50() {
    echo "g++ -std=c++11 -Wall -Werror ${1}.cpp -o $1";
    echo "";
    g++ -std=c++11 -Wall -Werror ${1}.cpp -o ${1}.o;

termbin() {
    cat $1 | nc 9999
    echo "cat $1 | nc 9999"

(Monkey Wrench) #10

Find the first ten of your most typed commands (good candidates to make an alias).

# Check alias candidates.
function check_ac() {
    history | \
        awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' \
            | grep -v "./" | column -c3 -s " " -t | sort -nr | nl |  head -n10
alias check_alias_candidates='check_ac'

(oaktree) #11

It turns out that my top two commands are ls and clear… probably because I spam them when I’m bored.

(Monkey Wrench) #12

Quick suggest - use ^L for clear, so it won’t show up in your hist.

(The C# Dude) #13

These are the ones I found useful in the last days:

alias getip='curl'
alias proxy='proxychains'
alias proxyip='proxychains curl'

(Command-Line Ninja) #14

Here’s another one for you ~/Bin/

ssh -p 4350 $opts $host -L $port:localhost:$port -N

Usage: hostname port flags
ex. 8384 -f

(-f is to fork into background), now you can access port 8384 which has binded to localhost on that server. (useful for services that automatically bind on rather than —>

(Full Snack Developer) #15

My alias list:

# User specific aliases and functions
alias attach="tmux attach -t"
alias be="bundle exec"
alias bu="bundle update"
alias ec="emacsclient -c -a emacs"
alias eq="qpaeq"
alias equalizer="qpaeq"
alias et="emacs -t"
alias ga="git add"
alias gc="git commit"
alias gcm="git commit -m"
alias gco="git checkout"
alias gds="git diff --staged"
alias gdu="git diff --unstaged"
alias gfa="git fetch --all"
alias gm="git merge"
alias gpsh="git push"
alias gpll="git pull"
alias gs="git status"
alias gu="git pull"
alias kops="${GOPATH}/bin/kops"
alias ll="ls -l"
alias lm="ls -l | more"
alias switch="tmux switch -t"
alias test-acceptance="bundle exec rspec spec/acceptance"
alias test-spec="bundle exec rake validate lint spec"
alias tf="terraform"
alias tfp="terraform plan"
alias vim="nvim"

(¯\_(ツ)_/¯) #16

I really like to see whats in the directory I change into, so
function cdls() { cd $1 ls } alias cd=cdls

(system) #17

This topic was automatically closed after 30 days. New replies are no longer allowed.