aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mkshrc384
-rw-r--r--mtr.misc.subr.sh213
2 files changed, 290 insertions, 307 deletions
diff --git a/mkshrc b/mkshrc
index 39bdd67..45386f6 100644
--- a/mkshrc
+++ b/mkshrc
@@ -1,15 +1,18 @@
-## Mitch's General shell configuration
-## MIT LICENSE
-# vim: syn=sh
-
-# How to install:
-# For Bash:
-# curl https://www.rygel.us/etc/mkshrc > $HOME/.mkshrc && echo '. $HOME/.mkshrc' >> .bashrc
-#
-# Personally I use this with mksh, .mkshrc is auto loaded by mksh
-
-# Nifty little line that will force the script to return if it's not runnking KSH
-# Automatically uncommented if installed system-wide with "install_mkshrc_system"
+# Copyright 2018 Mitchell Riedstra
+
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+
+# If you wish to prevent non KSH shells from running this
# [ -z "$KSH_VERSION" ] && return
# This will hopefully fix the bullshit with zsh
@@ -22,20 +25,6 @@ printf ""
else
-#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-# ____ _
-# | _ \ _ __ ___ _ __ ___ _ __ | |_
-# | |_) | '__/ _ \| '_ ` _ \| '_ \| __|
-# | __/| | | (_) | | | | | | |_) | |_
-# |_| |_| \___/|_| |_| |_| .__/ \__|
-# |_|
-# _____ _ _
-# | ___| _ _ __ ___| |_(_) ___ _ __ ___
-# | |_ | | | | '_ \ / __| __| |/ _ \| '_ \/ __|
-# | _|| |_| | | | | (__| |_| | (_) | | | \__ \
-# |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/
-#
-#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
precmd() {
typeset e=$?
@@ -81,13 +70,13 @@ set_prompt() {
# PS1="${USER:=$(id -un)}@$(hostname) \$PWD
echo $TERM | grep "256color$" > /dev/null 2>&1
if [ $? -eq 0 ] ; then
- BG=""
+ BG=""
ACCENT_C=""
ACCENT_P="|"
USER_C=""
PATH_C=""
END_C=""
- END_P="≈"
+ END_P="%"
else
BG=""
ACCENT_C=""
@@ -101,7 +90,7 @@ set_prompt() {
fi
}
set_basic_prompt() {
- PS1="$(precmd)${USER:=$(id -un)}@$(hostname) \$PWD $ "
+ PS1='$(precmd)'"${USER:=$(id -un)}@$(hostname) \$PWD $ "
export PS1;
}
set_super_basic_prompt() {
@@ -119,14 +108,6 @@ do_cd() {
# ZSH doesn't handle these functions all too well
fi
-#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-# _ _ _ _____ _ _
-# / \ | (_) __ _ ___ | ___| _ _ __ ___| |_(_) ___ _ __ ___
-# / _ \ | | |/ _` / __| | |_ | | | | '_ \ / __| __| |/ _ \| '_ \/ __|
-# / ___ \| | | (_| \__ \ | _|| |_| | | | | (__| |_| | (_) | | | \__ \
-# /_/ \_\_|_|\__,_|___/ |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/
-#
-#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
setaliases() {
alias ls="ls -F";
alias l="ls -lhF";
@@ -150,10 +131,14 @@ setcoloraliases() {
alias lm='CLICOLOR_FORCE="1" ls -l | less -r';
fi
- alias grep="grep --color=auto";
- alias egrep='egrep --color=auto'
+ grep --help | grep fucks - >/dev/null 2>&1
+ if [ $? -eq 0 ] ; then
+ alias grep="grep --color=auto";
+ alias egrep='egrep --color=auto'
+ alias search='egrep --color=auto -rnI';
+ fi
+
alias diff="$(which diff colordiff 2>/dev/null | tail -n 1)";
- alias search='egrep --color=auto -rnI';
alias t='tree -CdL'
}
@@ -220,10 +205,21 @@ 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="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
+COUNTER="1";
+while true ; do
+ sleep 1;
+ printf "\t$COUNTER\r";
+ COUNTER="$(echo $COUNTER+1 |bc )";
+done
}
# First argument is the interface on which to scan
ipv6_local_hosts() {
@@ -272,108 +268,6 @@ for dirname,subdirs,files in os.walk("."):
print max_dir, max_file'
}
-install_tmx() {
-location="/usr/local/bin/tmx"
-if ! [ -z $1 ]; then
- location="$1"
-fi
-echo '#!/bin/sh
-
-# Modified further by Mitchell Riedstra to be compatible with
-# /bin/sh
-
-#
-# Modified TMUX start script from:
-# http://forums.gentoo.org/viewtopic-t-836006-start-0.html
-#
-# Store it to `~/bin/tmx` and issue `chmod +x`.
-#
-
-# Works because bash automatically trims by assigning to variables and by
-# passing arguments
-trim() { echo $1; }
-
-if [ -z "$1" ]; then
- echo "Specify session name as the first argument"
- exit
-fi
-
-# Only because I often issue `ls` to this script by accident
-if [ "$1" == "ls" ]; then
- tmux ls
- exit
-fi
-
-base_session="$1"
-# This actually works without the trim() on all systems except OSX
-tmux_nb=$(trim `tmux ls | grep "^$base_session" | wc -l`)
-if [ "$tmux_nb" == "0" ]; then
- echo "Launching tmux base session $base_session ..."
- tmux new-session -s $base_session
-else
- # Make sure we are not already in a tmux session
- if [ -z "$TMUX" ]; then
- # Kill defunct sessions first
- old_sessions=$(tmux ls 2>/dev/null | egrep "^[0-9]{14}.*[0-9]+\)$" | cut -f 1 -d:)
- for old_session_id in $old_sessions; do
- tmux kill-session -t $old_session_id
- done
-
- echo "Launching copy of base session $base_session ..."
- # Session is is date and time to prevent conflict
- session_id=`date +%Y%m%d%H%M%S`
- # Create a new session (without attaching it) and link to base session
- # to share windows
- tmux new-session -d -t $base_session -s $session_id
- # Create a new window in that session
- #tmux new-window
- # Attach to the new session
- tmux attach-session -t $session_id
- # When we detach from it, kill the session
- tmux kill-session -t $session_id
- fi
-fi
-' > $location && chmod +x $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
-
-}
# System setup `chroot`, useful mainly on Linux
syschroot() {
CHDIR=$1
@@ -390,77 +284,6 @@ syschroot() {
umount $CHDIR/dev $CHDIR/sys $CHDIR/proc
PS1="$CUR_PS1"
}
-# Sometimes useful function for unmounting a chroot dir on Linux
-umount_recursive() {
- case $1 in
- -h|--help|"")
- cat <<-EOF
- Specifiy the full path to the mountpoint
- and this function will do it's best to
- unmount all child filesystems and the path
- specified
- Example:
- $0 /path/to/filesystem/with/lots/of/mountpoints
- Options:
- -f|--force
- EOF
- ;;
- -f|--force)
- local _path="$2"
- local filesystems=`cat /proc/mounts | grep $_path | awk '{print $2}' | sort -r`
- for filesystem in $filesystems ; do
- umount -f $filesystem
- done
- ;;
- *)
- local _path="$1"
- local filesystems=`cat /proc/mounts | grep $_path | awk '{print $2}' | sort -r`
- for filesystem in $filesystems ; do
- umount $filesystem
- done
- ;;
- esac
-}
-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';
-}
# Usage: dir_oct:file_oct path
setperms() {
@@ -475,27 +298,6 @@ timestamp() {
}
-#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-# ____ __ _ _ _
-# / ___|___ _ __ / _(_) __ _ _ _ _ __ __ _| |_(_) ___ _ __
-# | | / _ \| '_ \| |_| |/ _` | | | | '__/ _` | __| |/ _ \| '_ \
-# | |__| (_) | | | | _| | (_| | |_| | | | (_| | |_| | (_) | | | |
-# \____\___/|_| |_|_| |_|\__, |\__,_|_| \__,_|\__|_|\___/|_| |_|
-# |___/
-# __ __ _
-# | \/ | __ _ _ __ __ _ __ _ ___ _ __ ___ ___ _ __ | |_
-# | |\/| |/ _` | '_ \ / _` |/ _` |/ _ \ '_ ` _ \ / _ \ '_ \| __|
-# | | | | (_| | | | | (_| | (_| | __/ | | | | | __/ | | | |_
-# |_| |_|\__,_|_| |_|\__,_|\__, |\___|_| |_| |_|\___|_| |_|\__|
-# |___/
-# _____ _ _
-# | ___| _ _ __ ___| |_(_) ___ _ __ ___
-# | |_ | | | | '_ \ / __| __| |/ _ \| '_ \/ __|
-# | _|| |_| | | | | (__| |_| | (_) | | | \__ \
-# |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/
-#
-#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
pull() {
url=""
file=""
@@ -554,7 +356,7 @@ updateshell() {
updatevimrc() {
OLDWD="$(pwd)"
cd $HOME
- git clone https://git.riedstra.us/mitch/vim-cfg .vim
+ git clone $VIM_GIT_URL .vim
if [ $? -gt 0 ] ; then
cd $HOME/.vim
git pull origin master
@@ -586,12 +388,10 @@ setcolorterminal() {
case $TERM in
xterm*)
export TERM=xterm-256color
- set_title $(hostname)
# printf $'\033]0;'"$(hostname)"$'\007';
;;
screen*)
export TERM=screen-256color
- set_tmux_title $(whoami)
# printf $'\033k'"$(whoami)"$'\033\\';
;;
esac
@@ -618,21 +418,18 @@ colormanpages() {
export GROFF_NO_SGR=1
}
-#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-# __ __ _ _____ _ _
-#| \/ (_)___ ___ | ___| _ _ __ ___| |_(_) ___ _ __ ___
-#| |\/| | / __|/ __| | |_ | | | | '_ \ / __| __| |/ _ \| '_ \/ __|
-#| | | | \__ \ (__ | _|| |_| | | | | (__| |_| | (_) | | | \__ \
-#|_| |_|_|___/\___| |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/
-#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
set_editor() {
- # export EDITOR="vi"
+ if [ -z "$EDITORS" ] ; then
+ export EDITOR="vi"
+ else
+ export EDITOR="$(which $EDITORS 2>/dev/null | tail -n1)"
+ fi
- export EDITOR="$(which ed mg nano vi vim nvim vis-editor 2>/dev/null | tail -n1)"
export VISUAL="$EDITOR"
# Set an alias for our editor of choice
alias vi="$EDITOR"
+ alias vim="$EDITOR"
alias edit="$EDITOR"
alias e="$EDITOR"
}
@@ -643,105 +440,78 @@ set_lang() {
export CHARSET="$1";
export LANG="$1";
}
-#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-# ____ _ _ _
-# / ___|| |__ ___| | |
-# \___ \| '_ \ / _ \ | |
-# ___) | | | | __/ | |
-# |____/|_| |_|\___|_|_|
-#
-# ____ __ _ _ _
-# / ___|___ _ __ / _(_) __ _ _ _ _ __ __ _| |_(_) ___ _ __
-# | | / _ \| '_ \| |_| |/ _` | | | | '__/ _` | __| |/ _ \| '_ \
-# | |__| (_) | | | | _| | (_| | |_| | | | (_| | |_| | (_) | | | |
-# \____\___/|_| |_|_| |_|\__, |\__,_|_| \__,_|\__|_|\___/|_| |_|
-# |___/
+#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NEWLINE='$(printf "\n")'
SHELL_CONFIG=".mkshrc"
-FANCY_PROMPT=1
COLOR=1
-UPDATE_URL="https://www.rygel.us/etc/"
+MY_LANG="en_US.UTF-8"
-PRELOAD="$HOME/${SHELL_CONFIG}.pre"
-LOCAL="$HOME/${SHELL_CONFIG}.local"
-
-# For use with SSL functions
-# Just use easy-rsa, it's less hassle
-
-# Do not load our system profile
-# . /etc/profile
-
-
-############################################################
-########## Enviroment variables
-set_pager
-set_editor
+export EDITORS="ed vi vim nvim "
export PATH="$HOME/bin:$PATH"
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
-set_lang "en_US.UTF-8"
+UPDATE_URL="https://www.rygel.us/etc/"
+VIM_GIT_URL="https://git.riedstra.us/mitch/vim-cfg"
+
+PRELOAD="$HOME/${SHELL_CONFIG}.pre"
+LOCAL="$HOME/${SHELL_CONFIG}.local"
+
+# Don't put any variables below this, as they can't be overridden before the
+# functions if you do that
# Load pre config
if [ -e $PRELOAD ] ; then
. $PRELOAD
fi
+set_pager
+set_editor
+set_lang $MY_LANG
+
+setaliases
+setsudoaliases
+
+# Nasty conditional for support of many different shells
if
[ $SHELL = "/bin/ksh" ] ||
[ $SHELL = "/bin/mksh" ] ||
[ $SHELL = "/usr/bin/mksh" ] ||
- [ $SHELL = "/usr/local/bin/mksh" ]
+ [ $SHELL = "/usr/local/bin/mksh" ] ||
+ ! [ -z "$KSH_VERSION" ]
then
export HISTFILE="$HOME/.ksh_history"
set -o emacs
bind ^L=clear-screen
-
- setaliases
- setsudoaliases
-
if [ $COLOR -eq 1 ] ; then
set_prompt
- colormanpages
- setcolorterminal
- setcoloraliases
- setlscolors
+ else
+ set_basic_prompt
fi
elif [ $SHELL = "/bin/zsh" ] ||
[ $SHELL = "/usr/bin/zsh" ] ||
[ $SHELL = "/usr/local/bin/zsh" ] ; then
set -o emacs
- setaliases
- setsudoaliases
-
- if [ $COLOR -eq 1 ] ; then
- colormanpages
- setcolorterminal
- setcoloraliases
- setlscolors
- fi
else
- # Support other shells
- setaliases
- setsudoaliases
-
[ $SHELL = "/bin/sh" ] && set_super_basic_prompt
+fi
- if [ $COLOR -eq 1 ] ; then
- colormanpages
- setcolorterminal
- setcoloraliases
- setlscolors
- fi
+if [ $COLOR -eq 1 ] ; then
+ colormanpages
+ setcolorterminal
+ setcoloraliases
+ setlscolors
fi
# Include local configuration options
diff --git a/mtr.misc.subr.sh b/mtr.misc.subr.sh
new file mode 100644
index 0000000..268b1c9
--- /dev/null
+++ b/mtr.misc.subr.sh
@@ -0,0 +1,213 @@
+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
+}