Anonymous avatar Anonymous committed a18d615

change add_path, add exit status to prompt

Comments (0)

Files changed (2)

bash/bash_profile

 export HGRCPATH="$HOME/etc/hgrc"
 export MAILRC="$HOME/etc/mailrc"
 export TMPDIR="/tmp"
-export BUG_PROJECT="$HOME/.TODO"
 export HOSTFILE="/etc/hosts"
 export RLWRAP_HOME="$HOME/.rlwrap"
 
 export EDITOR=vim
 export VISUAL=vim
-export PAGER=vimpager
+#export PAGER=vimpager
+export PAGER=less
 export MANPAGER=less
+export SYSTEMD_PAGER=less
 
 source "$HOME/etc/bash/bashrc"
 
 	path="$1"
 	shift
 
-	while [ $# -gt 0 ]; do
-		new="$(echo $1 | sed 's_/$__')" # no trailing /
-		expand=$(eval echo \$$path)
+	IFS=: read -a dirs <<< "${!path}"
 
-		oIFS="$IFS"
-		IFS=":"
-
-		for dir in $expand; do
-			if [ "$dir" == "$new" ]; then
-				shift
-				IFS="$oIFS"
-				continue 2
-			fi
+	for n in "$@"; do
+		n="${n%/}"
+		for d in "${dirs[@]}"; do
+			[[ "$n" == "$d" ]] && continue 2
 		done
-
-		if [ -z "$expand" ]; then
-			eval $path="$new"
-		else
-			eval $path="$new:\$$path"
-		fi
-
-		IFS="$oIFS"
-		shift
+		dirs+="$n"
 	done
 
-	return 0
+	oIFS="$IFS"
+	IFS=:
+	printf -v "$path" "%s" "${dirs[*]}"
+	IFS="$oIFS"
 }
 
 init_colors () {
 	alias suvi='sudo -e'
 
 	alias m='rlwrap mail'
+
+	alias html='w3m -dump -T text/html'
 }
 
 
 init_prompt () {
-	PS1="\[$reset\][\[$green\]\h \[$magenta\]\W \[$red\]\!\[$reset\]]\$ "
-	[[ "$TERM" =~ "rxvt" ]] && PROMPT_COMMAND='echo -ne "\e]0;${USER}@${HOSTNAME%%.*}: ${PWD/$HOME/~}\a"'
-	PROMPT_COMMAND="history -a; $PROMPT_COMMAND" 
+	PS1="\[$reset\][\[$green\]\h \[$magenta\]\W \[$yellow\]\!\[$red\]\${rs:+ \$rs}\[$reset\]]\$ "
+	PROMPT_COMMAND='rs=${?#0}'
+	[[ "$TERM" =~ "rxvt" ]] && PROMPT_COMMAND="$PROMPT_COMMAND;"'echo -ne "\e]0;${USER}@${HOSTNAME%%.*}: ${PWD/#$HOME/~}\a"'
 }
 
 init_xirrus () {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.