-
-
Save sagz/6954209 to your computer and use it in GitHub Desktop.
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
# 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/vim' | |
# 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 [email protected]|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\] " | |
# 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'; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment