Skip to content

Instantly share code, notes, and snippets.

@vanokg
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save vanokg/0c9795016d56369336ce to your computer and use it in GitHub Desktop.
Save vanokg/0c9795016d56369336ce to your computer and use it in GitHub Desktop.
.bashrc
# put timestamps in my bash history
export HISTTIMEFORMAT='%F %T '
# don't put duplicate commands into the history
export HISTCONTROL=ignoredups
# record only the most recent duplicated command (see above)
export HISTCONTROL=ignoreboth
# don't record these commands in the history; who cares about ls?
export HISTIGNORE='pwd:ls:history:'
# keep the history size up to 4096 lines
export HISTSIZE=4096
# force my editor environment variable to be vim (the ONLY correct editor)
export EDITOR='/usr/bin/nano'
# a setting that does its best to keep ssh connections from freezing
export AUTOSSH_POLL=30
# get color settings for directory listings (ls)
eval `dircolors`
# list directories with color
alias ls='ls --color=auto'
# shortcut aliases for the ls command that render different types of output
alias dir='ls --color=auto --format=vertical'
alias ll='ls -Al'
alias la='ls -A'
alias lh='ls -Alh'
# highlight grep matches with color
alias grep='grep --color=auto'
# shortcut aliases for the grep command with different behaviors
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# put the date into your clipboard (you need to install xsel)
alias dateclip='date|xsel --clipboard'
# put a timestamp into your clipboard (style is YYYY-MM-DD-HH.MM.SS)
alias tsclip='echo -n "$(date +%Y-%m-%d-%H.%M.%S)"|xsel --clipboard'
# output a timestamp to the terminal (same format as above)
alias tstmp='date +%Y-%m-%d-%H.%M.%S'
# encrypt your clipboard using gpg
alias cryptclip="xsel|gpg -ear your@email.address|xsel --clipboard"
# pipe command output to your clipboard like this: command | putclip
alias putclip="xsel --clipboard"
# retrieve the contents of your clipboard and output it on STDOUT
alias getclip="xsel"
# handy command to show currently active and resource-heavy processes
alias procstat="ps -e -o pcpu,pid,cpu,nice,state,cputime,args --sort -pcpu | sed '/^ 0.0 /d'"
# install the "beep" command and try it out. if you've ever watched loony toons, you'll get it
alias wylie='l=20; x=1300; y=100; d=-5;for i in `seq $x $d $y`; do beep -l $l -f $i; done'
# ping a host until it comes up, then beep once and stop pinging. Simlar to the ping -a command
# but it will still work in cases where ping -a does not. you need to install "beep" first
beepwhenup () { PHOST="$@"; if [[ "$PHOST" == "" ]]; then echo 'Enter host you want to ping:'; read PHOST; fi; if [[ "$PHOST" == "" ]]; then echo 'No host to ping. Aborted.'; exit; fi; while true; do ping -c1 -W2 $PHOST 2>&1 >/dev/null; if [[ "$?" == "0" ]]; then for j in $(seq 1 4); do beep; done; ping -c1 $PHOST; break; fi; done; }
# tell your terminal to wrap lines correctly according to the window size, even if it changes
shopt -s checkwinsize
# recursively delete any vim swap files in your current directory tree. use wisely
alias vimclean="find . -iname '*sw[po]' -print -delete"
# how much memory is the given command name using? for example: howmuchmem vmware
howmuchmem () { PROCNAME="$@"; echo $PROCNAME IS USING $(echo "scale=4; ($(ps axo rss,comm|grep $PROCNAME| awk '{ TOTAL += $1 } END { print TOTAL }')/$(free | head -n 2 | tail -n 1 | awk '{ print $2 }'))*100"|bc)% of system RAM; };
# recursively change ownership of the given file or files, to the current user and group
alias chme='sudo chown -R $USER:$USER'
# show how many processes each user is running
alias procperuser='ps ax -o user | sort | uniq -c | sort -nr'
# show the processes consuming the most memory
memhogs () { TR=`free|grep Mem:|awk '{print $2}'`;ps axo rss,comm,pid|awk -v tr=$TR '{proc_list[$2]+=$1;} END {for (proc in proc_list) {proc_pct=(proc_list[proc]/tr)*100; printf("%d\t%-16s\t%0.2f%\n",proc_list[proc],proc,proc_pct);}}'|sort -n |tail -n 10; };
# make a fancy bash prompt, colorful, which includes your pwd and a timestamp
#export PS1="\n[\[\e[1;37m\]\u\[\e[0m\]@\[\e[1;34m\]\H\[\e[0m\]] [\[\e[1;33m\]\d, \t\[\e[0m\]] [\[\e[1;31m\]\!\[\e[0m\]]\n\[\e[1;31m\]\[\e[0m\][\[\e[1;37m\]\w\[\e[0m\]]\n\[\e[1;37m\]\\$\[\e[0m\] "
export PS1='\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\] \[\e[0;37m\]'
# monitor processor temperature from the commandline
coretemp () { /usr/bin/clear; while : ; do /usr/bin/sensors | /bin/grep ^Core | while read x; do /usr/bin/printf '% .23s\n' "$x"; done; /bin/sleep 1 && /usr/bin/clear; done; }
# monitor your nvidia graphics card temperature (GPU) from the command line
nvtemp () { /usr/bin/clear; while : ; do nvidia-settings -q '[gpu:0]/GPUCoreTemp' | perl -nE '/.*:\s(\d+)\.$/ && say "GPU temp: $1"'; /bin/sleep 1 && /usr/bin/clear; done; }
# customize your $PATH below. I like to include the /sbin family for myself
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin:/usr/sbin:/sbin
# show information about your nvidia graphics card
alias nvinfo='nvidia-settings -q [gpu:0]/GPUCoreTemp'
# aliases to make sure the family of "apt" commands is always run as root
# (debian and it's variants like ubuntu, mint, and arch)
alias apt-get='sudo apt-get'
alias aptitude='sudo aptitude'
alias dpkg='sudo dpkg'
# uncomment this if you have perlbrew installed; if you don't, you should consider it
# source ~/perl5/perlbrew/etc/bashrc
# turn perlbrew on and off
brewoff () { unset PERLBREW_ROOT; unset PERLBREW_HOME; echo 'perlbrew off'; }
brewon () { source ~/perl5/perlbrew/etc/bashrc; echo 'perlbrew on'; }
if [ -f /usr/bin/grc ]; then
alias cvs="grc --colour=auto cvs"
alias diff="grc --colour=auto diff"
alias esperanto="grc --colour=auto esperanto"
alias gcc="grc --colour=auto gcc"
alias irclog="grc --colour=auto irclog"
alias ldap="grc --colour=auto ldap"
alias log="grc --colour=auto log"
alias netstat="grc --colour=auto netstat"
alias ping="grc --colour=auto ping"
alias proftpd="grc --colour=auto proftpd"
alias traceroute="grc --colour=auto traceroute"
alias wdiff="grc --colour=auto wdiff"
alias mtr="grc --colour=auto mtr"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment