Last active
August 29, 2015 14:01
-
-
Save weidagang/d73fd8d656cc3beabbe9 to your computer and use it in GitHub Desktop.
Useful bash aliases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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