Useful Aliases in bash

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.

4 Likes

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"
3 Likes

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

Otherwise :

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

1 Like

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.

1 Like

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

1 Like

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

1 Like

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'

Clipboard

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

Pasting

alias pb="curl -sF "c=@${1:--}" -w "%{redirect_url}" 'https://ptpb.pw/?r=1' -o /dev/stderr | setclip"
alias cpb="getclip | pb"
alias paste="curl -F c=@- https://ptpb.pw/"
alias paste2="curl -F 'f:1=<-' ix.io"

chmod

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

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

1 Like

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 termbin.com 9999
    echo "cat $1 | nc termbin.com 9999"
}

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'
1 Like

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

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

2 Likes

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

alias getip='curl http://ipinfo.io/ip'
alias proxy='proxychains'
alias proxyip='proxychains curl http://ipinfo.io/ip'
3 Likes

Here’s another one for you ~/Bin/

portsync.sh

#!/bin/bash
host=$1
port=$2
opts=$3
ssh -p 4350 $opts $host -L $port:localhost:$port -N

Usage: portsync.sh hostname port flags
ex. portsync.sh 192.168.1.50 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 127.0.0.1 rather than 0.0.0.0)

192.168.1.50:8384 —> 127.0.0.1:8384

2 Likes

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"
1 Like

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

4 Likes

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