Skip to content

Commit

Permalink
many color/term fixes to accomodate Ubuntu, updated emacs-solarized, …
Browse files Browse the repository at this point in the history
…better-paths debugged and reintroduced
  • Loading branch information
edslocomb committed Jun 17, 2012
1 parent b9ea501 commit 530db47
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 155 deletions.
98 changes: 0 additions & 98 deletions bash/FreeBSD

This file was deleted.

98 changes: 98 additions & 0 deletions bash/better-paths
@@ -0,0 +1,98 @@
# -*- sh -*-

# # Add some user and/or local paths to $PATH and $MANPATH

# ###
# ### Add your dirs to [pre|post]PATH and [pre|post]MANPATH below.
# ### Dirs already in your PATH/MANPATH won't be added.
# ### Dirs that don't exist on your system won't be added.
# ### Dirs will be *prepended* to your PATH/MANPATH, order preserved.
# ###

prePATH="$HOME/bin:$HOME/.scripts:$HOME/.rvm/bin"

postPATH="/usr/local/mysql/bin:/usr/local/git/bin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin"

preMANPATH="/usr/local/mysql/man:/usr/local/git/man:/usr/local/man:/opt/local/man"

postMANPATH="$HOME/man:$HOME/.rvm/man"

# # Note on $MANPATH, $extraMANPATH
# # we don't want to set $MANPATH if the system/user is using another
# # mechanism to find man pages (e.g. manpath(1) on ubuntu or freebsd),
# # because setting MANPATH could clobber that mechanism.
# # manpath(1) will use $PATH to find man pages; for the most
# # part, if you add something to [pre|post]PATH, then manpath(1) will
# # pick up your corresponding man pages.


# ##
# ## Function definitions
# ##

list_contains () {
eval p=\$$1
for dir in $p
do
if [ "$dir" == "$2" ]; then
return 0
fi
done
return 1
}

prepend_to_listvar () {
if [ -d $2 ] && ! ( list_contains "$1" "$2" ) ; then
eval "$1=$2${IFS:0:1}\$$1"
fi
}

append_to_listvar () {
if [ -d $2 ] && ! ( list_contains "$1" "$2" ) ; then
eval "$1=\$$1${IFS:0:1}$2"
fi
}

reverse_list () {
rev=$1
shift
while [ $1 ]
do
rev=$1${IFS:0:1}$rev
shift
done
echo -n "$rev"
}

# ##
# ## End function definitions
# ##

# # we're going to work with paths separated by ":" instead of whitespace
IFS=:

for dir in $( reverse_list $prePATH )
do
prepend_to_listvar PATH "$dir"
done

for dir in $postPATH
do
append_to_listvar PATH "$dir"
done

if [ -n "$MANPATH" ]; then
for dir in $( reverse_list $preMANPATH )
do
prepend_to_listvar MANPATH "$dir"
done
for dir in $postMANPATH
do
append_to_listvar MANPATH "$dir"
done
export MANPATH
fi

# # put IFS back
unset IFS

24 changes: 24 additions & 0 deletions bash/colorfixes
@@ -0,0 +1,24 @@
# -*- sh -*-

# set TERM correctly if we're in Ubuntu's default graphical terminal app,
# (gnome-terminal, in Ubuntu 12.04)
if [[ ($TERM == "xterm") && ($COLORTERM == "gnome-terminal") ]]; then
TERM=gnome-256color
fi

# Fix GNU screen's 256-color terminal setttings
# the presence of $STY is the most reliable way to detect when we're
# running inside screen. note TERMCAP is not the same as TERM
if [ $STY ]; then
# we're running inside GNU screen...
if [ -n "$TERMCAP" ]; then
# ...where the $TERMCAP screen sets is wrong for 256-color terminals...
if (( `expr "$TERM" : '.*256col'` )); then
# ...so we blow it away, assuming either the system-wide
# termcap will have something better, or we have
# taken advantage of $TERMPATH and/or .termcap, or
# we'll be setting $TERMCAP ourselves after this
unset TERMCAP
fi
fi
fi
File renamed without changes.
6 changes: 1 addition & 5 deletions bash_profile
Expand Up @@ -3,13 +3,9 @@
# Read by login shells only (the first time you log in).
# NOT read by subshells (like what screen creates).

source ~/.bash/paths

source $HOME/.bash/better-paths

# .bashrc is read by subshells. This will make login shells read it too.
if [ -f $HOME/.bashrc ]; then
source $HOME/.bashrc
fi



2 changes: 1 addition & 1 deletion bashrc
Expand Up @@ -14,7 +14,7 @@
source ~/.bash/aliases
source ~/.bash/completions
source ~/.bash/config
source ~/.bash/`uname`
source ~/.bash/colorfixes

# Use .localrc for settings specific to one system.
if [ -f ~/.localrc ]; then
Expand Down

0 comments on commit 530db47

Please sign in to comment.