Skip to content

Instantly share code, notes, and snippets.

@tommybutler
Last active December 25, 2015 09:29
Show Gist options
  • Save tommybutler/6954156 to your computer and use it in GitHub Desktop.
Save tommybutler/6954156 to your computer and use it in GitHub Desktop.
I source this file from the last line in my .bashrc. I name it .profile-custom and put it in my home directory
shopt -s checkwinsize
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 HISTTIMEFORMAT='%F %T '
export HISTCONTROL=ignoredups
export HISTCONTROL=ignoreboth
export HISTIGNORE='pwd:ls:history:'
export HISTSIZE=4096
export EDITOR='/usr/bin/vim'
export AUTOSSH_POLL=30
if [[ -x "`which dircolors`" ]]; then eval `dircolors`; fi
alias ls='ls --color=auto'
alias dir='ls --color=auto --format=vertical'
alias ll='ls -Al'
alias la='ls -A'
alias lh='ls -Alh'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias dateclip='date|xsel --clipboard'
alias tsclip='echo -n "$(date +%Y-%m-%d-%H.%M.%S)"|xsel --clipboard'
alias tstmp='date +%Y-%m-%d-%H.%M.%S'
alias cryptclip="xsel|gpg -ear [email protected]|xsel --clipboard"
alias putclip="xsel --clipboard"
alias getclip="xsel"
alias procstat="ps -e -o pcpu,pid,cpu,nice,state,cputime,args --sort -pcpu | sed '/^ 0.0 /d'"
alias wylie='l=20; x=1300; y=100; d=-5;for i in `seq $x $d $y`; do beep -l $l -f $i; done'
alias nvinfo='nvidia-settings -q [gpu:0]/GPUCoreTemp'
alias apt-get='sudo apt-get'
alias aptitude='sudo aptitude'
alias dpkg='sudo dpkg'
alias whois='whois -H'
alias chme='sudo chown -R $USER:$USER'
alias procperuser='ps ax -o user | sort | uniq -c | sort -nr'
alias vimclean="find . -iname '*sw[po]' -print -delete"
alias rsynctousb='sudo rsync --recursive --itemize-changes --no-owner --no-group --no-times --ignore-times --partial --modify-window=5'
alias itemize_changes='rsync --dry-run --archive --itemize-changes --checksum'
# functions
dropcaches () { sudo bash -c 'sync && sync && sync && echo 3 > /proc/sys/vm/drop_caches' ; }
tsbk () { file=$1; if [[ "$file" == '' ]]; then return; fi; cp -v "$file" "${file}-$( tstmp )"; }
coretemp ()
{
clear
while true ;
do
sensors | grep ^Core | \
while read x;
do
printf '% .23s\n' "$x"
done
sleep 1 && clear
done
}
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
}
beepwhenup ()
{
PHOST="$@";
if [[ "$PHOST" == '' ]];
then
echo 'Enter host you want to ping:'
read PHOST;
fi;
if [[ "$PHOST" == '' ]];
then
echo 'No host to ping. Aborted.'
return 1
fi;
while true ;
do
ping -c1 -W2 $PHOST 2>&1 >/dev/null;
if [[ "$?" -eq 0 ]];
then
for j in $(seq 1 4);
do
beep
done;
ping -c1 $PHOST
break
fi
done
return 0
}
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;
}
nvtemp ()
{
clear;
while true ;
do
nvidia-settings -q '[gpu:0]/GPUCoreTemp' | perl -nE '/.*:\s(\d+)\.$/ && say "GPU temp: $1"'
sleep 1 && clear;
done
}
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin:/usr/sbin:/sbin
# PerlBrew
if [[ -e ~/perl5/perlbrew/etc/bashrc ]]; then source ~/perl5/perlbrew/etc/bashrc ; fi
brewoff () { unset PERLBREW_ROOT; unset PERLBREW_HOME; echo 'perlbrew off'; }
brewon () { source ~/perl5/perlbrew/etc/bashrc; echo 'perlbrew on'; }
if [[ -e ~/.ssh-aliases ]]; then source ~/.ssh-aliases ; fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment