Show me your Bash Functions / Aliases!

flrichar

Fred Richards

Posted on September 21, 2019

Show me your Bash Functions / Aliases!

Do any of you have your favorite bash functions or aliases? I've always been a fan of quick "lightning tips" that you can show maybe on one line, and do something specific.

Here are some of mine!


## timestamp dmesg with the current date, this sudo doesnt require password
alias datemsg='date | sudo tee /dev/kmsg'

## how many ms since the epoch?
alias epocms='date +%s%3N'

## ksm is kernel same-page merging for virtual machines,
## this allows me to keep tabs on performance and metrics
alias ksm-info='~/opt/ksm-info.sh'

( ksm-info is just a one-liner ...
for ki in /sys/kernel/mm/ksm/* ; do echo -n "$ki: " ; cat $ki ; done
...)

## normal mutt is gmail, mm == local mail
alias mm='mutt -f ~/Mail/fredr'

## python pretends to be jq sometimes
alias pj='python -m json.tool'

## run a lot of ansible playbooks ... plans == play ansible
alias plans='ansible-playbook'

### .bashrc functions

## check on kernel entropy for ssh, vpn, encryption
entropy () { cat /proc/sys/kernel/random/entropy_avail; }

## pipe colorfied jq to less while keeping colors
jql () { jq -C . $1 | less -R ; }
Enter fullscreen mode Exit fullscreen mode

Many other minor stuff too, like loading environment vars for Go or BC.
So what are some of yours?

💖 💪 🙅 🚩
flrichar
Fred Richards

Posted on September 21, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Show me your Bash Functions / Aliases!