Skip to content

Instantly share code, notes, and snippets.

@researcx
Last active Jan 9, 2019
Embed
What would you like to do?
Random shell aliases I use
# this is not a full .bashrc file!
# copy aliases you want or need for your own .bashrc
# some of these aliases will also easily work in other shells such as fish! (~/.config/fish/config.fish)
# reload bashrc
alias rl='. ~/.bashrc' #reload .bashrc
# info/find/usful
alias psg="ps aux | grep" # usage: psg <process name> - quick ps grep.
alias hsg="history | grep" # usage: hsg <string> - quick history grep.
alias portuse="netstat -alpn | grep" # usage: portuse <port> - display info on used port
alias findin='egrep -rl' # usage: findin <string> <path> [--include=\*.txt] (or other egrep args) - find a string in any file (or a file of specified type) in the current folder recursively
alias ipinfo="wget -qO- https://a52.io/s/ip/ ; echo" # display external (public) ip
alias snapshot-page "wget -E -H -k -K -nd -N -p -P" # usage: snapshot-page <title> <url> - snapshots a single page
alias snapshot-path "wget -E -k -K -nd -N -p -np -r -e robots=off -P" # usage: snapshot-path <title> <url> - snapshots a whole web path/folder
# add colors to output
alias ls='ls -haltor --color=auto' # ls color + better listing
alias dir='dir --color=auto' # dir color
alias vdir='vdir --color=auto' # vdir color
alias grep='grep --color=auto' # grep color
alias fgrep='fgrep --color=auto' # fgrep color
alias egrep='egrep --color=auto' # egrep color
alias ll='ls -l' # ls alias 1
alias la='ls -A' # ls alias 2
alias lc='ls -CF' # ls alias 3
# add verbosity
alias cp='cp -v' # verbose copy
alias rm='rm -v --preserve-root' # verbose remove + preserve root
# misc useful
alias lock="xlock -mousemotion +description -mode blank -bg black -fg grey30" #lock desktop, requires xlock/xlockmore
alias freemem="sudo sh -c 'sync; echo 3 > /proc/sys/vm/drop_caches'" #free up ram
alias nano='nano -w' #don't warp long lines (seriously breaks files if in small terminal)
alias reboot="sudo shutdown -r now" #reboot
# git
alias ga='git add'
alias gp='git push'
alias gl='git log'
alias gs='git status'
alias gd='git diff'
alias gdc='git diff --cached'
alias gm='git commit -m'
alias gma='git commit -am'
alias gb='git branch'
alias gc='git checkout'
alias gra='git remote add'
alias grr='git remote rm'
alias gpu='git pull'
alias gcl='git clone'
# pacman
alias pac-upg='sudo pacman -Syu'
alias pac-upd='sudo pacman -Sy && sudo abs'
alias pac-insd='sudo pacman -S --asdeps'
alias pac-mir='sudo pacman -Syy'
alias pac-ins='sudo pacman -S'
alias pac-re='sudo pacman -R'
alias pac-rem='sudo pacman -Rns'
alias pac-info='sudo pacman -Si'
alias pac-search='sudo pacman -Ss'
alias pac-localinfo='sudo pacman -Qi'
alias pac-locsearch='sudo pacman -Qs'
alias pac-orphans="sudo pacman -Qdt"
alias pac-cache="sudo sudo pacman -Scc"
alias pac-files="sudo pacman -Ql"
alias pac-mark="sudo pacman -D --asexp"
alias pac-unmark="sudo pacman -D --asdep"
alias pac-unlock="sudo rm /var/lib/pacman/db.lck"
alias pac-lock="sudo touch /var/lib/pacman/db.lck"
#alias pac-remorphans="sudo pacman -Rns $(pacman -Qtdq)" #this may or may not seriously fuck up your pc
# yaourt (recommend using yay instead)
alias yaourtnc="yaourt --noconfirm"
alias yaourts="yaourt search"
alias yaourti="yaourt -S"
alias yaourtr="yaourt -R"
alias yaourtu="yaourt -Syua"
# yum (centos)
alias yumi="sudo yum -y install"
alias yumupd="sudo yum update"
alias yumupg="sudo yum upgrade"
alias yumr="sudo yum remove"
# functions
# generate a password
passgen() {
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo;
}
# calculator
function calc() {
echo "${1}"|bc -l;
}
# decompress
function decom () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment