Skip to content

Instantly share code, notes, and snippets.

@schmmd
Created October 21, 2011 03:04
Show Gist options
  • Save schmmd/1303009 to your computer and use it in GitHub Desktop.
Save schmmd/1303009 to your computer and use it in GitHub Desktop.
bashrc.sh
# make a TAB variable globally accessible
export TAB=`echo -e "\t"`
# sort compares binary data
export LC_ALL=C
# search for a file and open it with vim
function vimfind() {
if [ "$1" == "-s" ]
then
# prompt user to select the file
shift
select file in $(find ./* -type f -name "$@"); do
vim $file
break;
done;
else
# open all files
local files=$(find ./* -type f -name "$@");
echo $files
if [ -n "$files" ]
then vim $files
else echo "No such file found."
fi;
fi
}
# count the number of tab-separated columns in a file.
function colcount {
head -1 | awk -F\\t '{print NF}'
}
# commands that help make using tabs easier
function tuniqc {
uniq -c | sed 's/^\s*\([0-9][0-9]*\)\s*\(.*\)$/\1\t\2/g'
}
function tgroup {
sort | uniq -c | sed 's/^\s*\([0-9][0-9]*\)\s*\(.*\)$/\2\t\1/g'
}
alias tawk='awk -F\\t'
alias tsort='sort -t"$TAB"'
function notify {
eval "$*"
if [ $? -eq 0 ]
then
notify-send -t 300000 -u critical "'$*' succeeded"
else
notify-send -t 300000 -u critical "'$*' failed"
fi
}
export HISTSIZE=10000
export HISTIGNORE="ls:exit:[bf]g"
# append commands to the history file, rather than overwritingp
shopt -s histappend
# save each command right when it is executed, not at the end of the session
PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment