Skip to content

Instantly share code, notes, and snippets.

@weidagang
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weidagang/d73fd8d656cc3beabbe9 to your computer and use it in GitHub Desktop.
Save weidagang/d73fd8d656cc3beabbe9 to your computer and use it in GitHub Desktop.
Useful bash aliases
# Bash command aliases and utils
# code format
function astyle-java {
astyle --mode=java --style=linux -s4 $@
}
function astyle-c {
astyle --mode=c --style=linux -s4 $@
}
# get parent pid
function ppid {
ps -p ${1:-$$} -o ppid=
}
# search pattern in the files under the current dir
function search-text {
grep -nHr "$1" .
}
# decimal to hex
function hex { bc <<< "obase=16; $1"; }
function hex2decimal { bc <<< "ibase=16; baseobase=10; $1"; }
# copy & paste
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
# join lines with a delimiter
function join-lines { paste -s -d$1; }
# show my ip on eth0
alias show-ip="ifconfig eth0 | grep 'inet addr:' | sed -r 's/.*addr:(.*) Bcast:.*/\1/'"
# find which package a command belongs to
function which-pkg { dpkg -S $1 | egrep -w $(which $1)$; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment