Browse files

Merge branch 'master' of

  • Loading branch information...
devonjones committed Mar 23, 2011
2 parents 639fddb + 63d7748 commit 1b1884420a6836f4f630cda6e613392c47f913ed
@@ -0,0 +1,58 @@
+structured bashrc to allow for much easier understanding and handling of what shell changes you have set up.
+Instead of keeping my bashrc all in one file that becomes a giant mess, I've split the file out into a bunch of small shell scripts that the main bashrc automatically imports. This results in the followingdirectory setup:
+The base .bashrc (or can be renamed .bash_profile for those of you that use .bash_profile instead) contains only 4 things:
+1) a break for non interactive shells that stops any of it loading
+2) The addition of ~/bin to the path
+3) definition of the include_d function
+4) imports of the 3 above directories.
+Inside each directory, only files with the .sh extension will be sourced. The directory names are obvious, but I'll detail what's contained just to be complete.
+This directory is intended to hold a bunch of files setting up all of your aliases. It's preferred to keep only aliases that are closely related in the same file so that other people can easily pick up chucks of your alias behavior without having to import it all. Personally, I keep one for color terminals, my editor, filesystem commands and then a series of alias files for dealing with individual programs.
+Personally I find bash completion super useful, so I keep a whole directory for dealing with completions. Timple, one file per program is the expected usage.
+This directory is much more of a grab bag then the above two. It contains a seperate file for each discrete functional behavior I'm making to my shell. Some files contain only actual bash functions, some add functionality like eternal_bash_history.
+Until I get around to creating an install program, my suggestion is that you do the following to install this:
+1) Copy the contents of bashrc and append it onto the end of your .bashrc or .bash_profile
+ `cat bashrc >> ~/.bashrc`
+ -or-
+ `cat bashrc >> ~/.bash_profile
+2) Create your .d directories
+ `mkdir ~/.bash_aliases.d ~/.bash_completion.d ~/.bash_functions.d`
+3) Symlink any functionality you want from bash_magic into the appropriate directory
+ `cd ~/.bash_functions.d`
+ `ln -s <bash_magic project dir>/.bash_functions/`
+ <repeat as needed>
+4) Go through your existing .bashrc/.bash_profile and pull coherent chunks of functionality out and stuff it into new files in the appropriate directory
+5) Live a happier life knowing that your old messy bashrc is now a heck of a lot easier to understand.
@@ -11,5 +11,5 @@ alias trm=' rm'
alias tarc=' archive'
alias tdo=' do'
alias tsch=' schedule'
-alias gt="/usr/bin/gvim --servername GVIM --remote ~/Dropbox/todo/todo.txt"
+alias gt="/usr/bin/gvim --servername GVIM --remote $HOME/Dropbox/todo/todo.txt"
File renamed without changes.
@@ -2,7 +2,7 @@
# the ~/.bash_aliases file.
add_alias () {
local name=$1 value="$2"
- echo alias $name=\'$value\' >>~/.bash_aliases
+ echo alias $name=\'$value\' >> $HOME/.bash_aliases
eval alias $name=\'$value\'
alias $name
@@ -1,11 +1,3 @@
-if [ -d ~/.bash_completion.d -a -r ~/.bash_completion.d -a \
- -x ~/.bash_completion.d ]; then
- for i in ~/.bash_completion.d/*; do
- [[ ${i##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|*.rpm@(orig|new|save)) ]] &&
- [ \( -f $i -o -h $i \) -a -r $i ] && . $i
- done
# auto-completion is not case sensitive anymore
set completion-ignore-case On
@@ -14,5 +14,5 @@ shopt -s histappend
shopt -s histverify
# Create ~/.bash_eternal_history
-PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND ; }"'echo $$ $USER "$(history 1)" >> ~/.bash_eternal_history'
+PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND ; }"'echo $$ $USER "$(history 1)" >> $HOME/.bash_eternal_history'
@@ -32,7 +32,7 @@ unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
- PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
5 bashrc
@@ -5,12 +5,13 @@ export PATH=$PATH:$HOME/bin
function include_d {
- if [ -d ~/.$dir.d -a -r ~/.$dir.d -a -x ~/.$dir.d ]; then
- for i in ~/.$dir.d/*.sh; do
+ if [ -d $HOME/.$dir.d -a -r $HOME/.$dir.d -a -x $HOME/.$dir.d ]; then
+ for i in $HOME/.$dir.d/*.sh; do
. $i
include_d bash_functions
include_d bash_aliases
+include_d bash_completion

0 comments on commit 1b18844

Please sign in to comment.