Bashrc

From Attie's Wiki
Revision as of 07:53, 13 April 2017 by Attie (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Below is the extended contents of my ~/.bashrc_mine file (include it from ~/.bashrc)

if [ "$ATTIE_PATH" == "" ]; then
	export PATH=~/.bin:$PATH
	export ATTIE_PATH=done
fi
 
if [ -x $(which screen) ]; then
	if [ "$STY" ]; then
		alias is='echo yes'
		alias exit='screen -d $STY'
		alias qs='kill `echo $STY|cut -d "." -f 1`'
	else
		alias is='echo no'
		alias us='screen -d -R uni'
		alias ss='screen -S `date "+screen_%d-%b-%Y_%k:%M.%S"`'
		alias sl='screen -list'
		alias sc='screen -d -R'
	fi
else
	echo "WARNING: /usr/bin/screen was not found. screen aliases not inserted..."
fi
 
export EDITOR="vim"
 
if [ "$WINDOWID" != "" ]; then
	xrdb ~/.Xresources
fi
 
alias admesg='sudo tail -n 0 -f /var/log/messages'
alias pingdd='sudo killall -USR1 dd'
alias mps='ps -U $USER -f'
alias nano='nano -wzSA -T 2'
alias less='less -cR'
alias su='sudo su'
alias l='ls'
alias ll='ls -l'
alias lll='ls -la'
alias llp='ll *.patch'
alias x='exit'
alias j='jobs'
 
umask 0022
 
case "${TERM}" in
	"xterm" | \
	"screen")
		######################
		### setup a nice prompt for xterm ###
		function resolve_dirname() {
			local DEFAULT="${1-\w}"; shift
			local DIR=$(pwd)
			awk -F : "BEGIN{rc=1}{if(\$1==\"${DIR}\"){printf \$2;rc=0;nextfile}}END{exit rc}" ~/.dir_names 2>/dev/null || echo -n "${DEFAULT}"
		}
		function compile_prompt() {
			local RET=${1-?}; shift
			if [ "$(whoami)" == "root" ]; then
				local HASH_START="\e[0m\]#\e[91m\]#\e[31m\]#\e[0m "
				local HASH_END=" \e[31m\]#\e[91m\]#\e[0m\]#\e[0m"
			else
				local HASH_START="\e[0m\]#\e[94m\]#\e[34m\]#\e[0m "
				local HASH_END=" \e[34m\]#\e[94m\]#\e[0m\]#\e[0m"
			fi
 
			echo -n "\[\e]0;${PS1_TITLE-$(resolve_dirname) \h} \007\]"
			echo -n "${HASH_START}\e[0;33m\]\T \e[32m\]\u\e[90m\]@\e[35m\]\h\e[90m\]:\e[36m\[\w\e[0m\] [\j]${HASH_END}"
			[ "${RET}" != "0" ] && echo -n " \e[91m${RET}"
			[ ${BASH_DEPTH-0} -gt 0 ] && echo -n " \e[90m{${BASH_DEPTH-?},${BASH_OPWD-?}}"
			echo "\e[0m"
			echo -n "${PS1_PROMPT-$ }"
		}
		export PS1="${PS1_PROMPT-$ }"
		export PROMPT_COMMAND='export PS1="$(compile_prompt $?)"'
		### end the prompt bit ###
		##########################
		;;
 
	*)
		export PS1="\e[32m\]\u@\h:\w$\e[0m\] "
		unset PROMPT_COMMAND
		;;
esac
 
if [ "${BASH_DEPTH}" == "" ]; then
	export BASH_DEPTH=0
else
	export BASH_DEPTH=$((BASH_DEPTH + 1))
	export BASH_OPWD="$(pwd)"
fi
 
alias xterm='BASH_DEPTH="" xterm'
 
export HISTSIZE=10000
export HISTFILESIZE=10000
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox