updatevimrc() { OLDWD="$(pwd)" cd $HOME git clone https://git.riedstra.us/mitch/vim-cfg .vim if [ $? -gt 0 ] ; then cd $HOME/.vim git pull origin master else cd $HOME/.vim fi ./setup.sh && \ ./link-vimrc.sh cd $OLDWD } # Run Steam unfuck_steam() { LD_PRELOAD='/usr/$LIB/libstdc++.so.6 /usr/$LIB/libgcc_s.so.1 /usr/$LIB/libxcb.so.1 /usr/$LIB/libgpg-error.so' /usr/bin/steam } counter_figlet() { COUNTER="1"; while true ; do figlet "$COUNTER" ; COUNTER="$(echo $COUNTER+1 |bc )" ; sleep 1 ; clear ; done } counter_single_line() { COUNTER="1"; while true ; do sleep 1 ; printf "\t$COUNTER\r" ; COUNTER="$(echo $COUNTER+1 |bc )" ; done } pulltermcolors() { file="$HOME/bin/terminal-colors" if ! [ -d $HOME/bin ] ; then mkdir $HOME/bin fi pull -u ${UPDATE_URL}/terminal-colors -f $file chmod +x $file } pkg_switch_branch() { _f="/etc/pkg/FreeBSD.conf" cp $_f ${_f}.orig sed -e's/quarterly/latest/' < ${_f}.orig > ${_f} } find_most_recent_python() { _python="$(which python2 2>/dev/null)" $_python -c 'import os max_mtime = 0 for dirname,subdirs,files in os.walk("."): for fname in files: full_path = os.path.join(dirname, fname) mtime = os.stat(full_path).st_mtime if mtime > max_mtime: max_mtime = mtime max_dir = dirname max_file = fname print max_dir, max_file' } install_tmx() { location="/usr/local/bin/tmx" if ! [ -z $1 ]; then location="$1" fi TMP=$(mktemp) pull -u "https://www.rygel.us/etc/tmx.sh" -o "$TMP" install -m 555 "$TMP" "$location" && echo "Installed to $location" } find_most_recent() { if [ "$(uname)" != 'linux'] ; then path="0" while [ $# -gt 0 ] ; do case $1 in -p) path="$2"; shift; shift; ;; esac done if [ $path = "0" ] ; then find "$path" -printf "%T@ %Tc %p\n" | sort -n else echo "You need to specify a path with -p" fi else echo "GNU Find only" fi } startup_zram() { size="512M" while [ $# -gt 0 ] ; do case $1 in -s) size="$2" shift; shift; ;; *) echo "Unknown option $1" shift; ;; esac done modprobe zram zramctl --find --size="$size" mkswap -f /dev/zram0 swapon /dev/zram0 } time_at_yac() { date --date='September 22 2014' } find_php_short_tags() { egrep --include="*.php" -rniI '<\?[^px=q]' . --color=force } gentags() { options="-R --links --languages=php,-javascript" dir="." while [ $# -gt 0 ] ; do case $1 in -o) options="$2" shift; shift; ;; esac done if [ -x $(which exctags 2>/dev/null) ] ; then $(which exctags 2>/dev/null) $options $dir elif [ -x $(which ctags 2>/dev/null) ] ; then $(which ctags 2>/dev/null) $options $dir fi } set_tmux_title() { text="" while [ $# -gt 0 ] ; do text="$( echo $text $1)"; shift; done printf $'\033k'"${text}"$'\033\\'; } set_title() { text="" while [ $# -gt 0 ] ; do text="$( echo $text $1)"; shift; done printf $'\033]0;'"$text"$'\007'; } set_ps1() { PS1='$(precmd)${BG}${ACCENT_C}${ACCENT_P}${USER_C}${USER:=$(id -un)}@$(hostname)${ACCENT_C}${ACCENT_P} ${ACCENT_P}${PATH_C}${PWD:-?}${ACCENT_C}${ACCENT_P}${END_C} ${END_P} ' export PS1; } set_root_ps1() { PS1='$(precmd)${BG}${ACCENT_C}${ACCENT_P}${HOST_C}$(hostname)${ACCENT_C}${ACCENT_P} ${ACCENT_P}${PATH_C}${PWD:-?}${ACCENT_C}${ACCENT_P}${END_C} ${END_P} ' export PS1; } # RED: 31, GREEN: 32, YELLOW: 33, BLUE: 34, MAGENTA: 35, CYAN: 36, WHITE: 37, GREY 38. and No color which is 0. set_prompt() { if [ `id -u` -eq 0 ] ; then # Previously # Red for root, and no username # PS1="$(hostname) \$PWD echo $TERM | grep "256color$" > /dev/null 2>&1 if [ $? -eq 0 ] ; then BG="" ACCENT_C="" ACCENT_P="|" HOST_C="" PATH_C="" END_C="" set_root_ps1 END_P="#" else BG="" ACCENT_C="" ACCENT_P="|" HOST_C="" PATH_C="" END_P="#" fi set_root_ps1 else # Previously # PS1="${USER:=$(id -un)}@$(hostname) \$PWD echo $TERM | grep "256color$" > /dev/null 2>&1 if [ $? -eq 0 ] ; then BG="" ACCENT_C="" ACCENT_P="|" USER_C="" PATH_C="" END_C="" END_P="≈" else BG="" ACCENT_C="" ACCENT_P="|" USER_C="" PATH_C="" END_C="" END_P="$" fi set_ps1 fi }