Skip to content

Commit

Permalink
Renamed files so not hidden files within the repo... added --force fl…
Browse files Browse the repository at this point in the history
…ag to force relinking.

also changed the condition for which repo being "dirty" is determined....
If you are using an old git you do not have the --ingore-submodules flag.
  • Loading branch information
Gavin M. Bell committed Feb 10, 2013
1 parent f75c766 commit a1fbacc
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 8 deletions.
0 .bash_aliases → bash_aliases
100755 → 100644
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions .git_bashrc → git_bashrc
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ __git_remote_dist() {
#is branch dirty?
GIT_THEME_PROMPT_DIRTY='*'
__parse_git_dirty() {
if [[ -n "$(git status --porcelain --ignore-submodules 2> /dev/null)" ]]; then
#if [[ $(git diff --shortstat 2> /dev/null ) != "" ]]; then
#if [[ -n "$(git status --porcelain --ignore-submodules 2> /dev/null)" ]]; then
if [[ -n "$(git diff --shortstat 2> /dev/null )" ]]; then
echo -e "$GIT_THEME_PROMPT_DIRTY"
else
echo -e "$GIT_THEME_PROMPT_CLEAN"
Expand Down
19 changes: 13 additions & 6 deletions setup
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

DEBUG=0
DRY_RUN=0
FORCE=0

homedir=${homedir:-${HOME:?"HOME environment var must be set!!!!"}}

Expand Down Expand Up @@ -94,20 +95,22 @@ setup_dot_bash_files() {
echo -n "setting up $dot_file... "

#exclusion for the .bash_profile file - only link if not already present in ${homedir}
if [ "${dot_file}" = ".bash_profile" ] && [ -e ${homedir}/${dot_file} ]; then
if [ "${dot_file}" = "bash_profile" ] && [ -e ${homedir}/.${dot_file} ]; then
((DEBUG)) && echo "Already have a .bash_profile present, will not alter" || echo "[OK] <skipping>"
continue
fi

#check if the file exists already
if [ "$(_readlinkf ${dot_file})" == "$(_readlinkf ${homedir}/${dot_file} | tail -n 1)" ]; then
if [ "$(_readlinkf ${dot_file})" = "$(_readlinkf ${homedir}/.${dot_file} | tail -n 1)" ]; then
echo "[OK] (nothing to do already linked)"
else
((DEBUG|DRY_RUN)) && echo "[ -e ${homedir}/${dot_file} ] && mv -v ${homedir}/${dot_file}{,.bak}"
((! DRY_RUN)) && [ -e ${homedir}/${dot_file} ] && mv -v ${homedir}/${dot_file}{,.bak}
((DEBUG||DRY_RUN)) && echo "ln -s $(_readlinkf ${dot_file}) ${homedir}/${dot_file}"
((DEBUG|DRY_RUN)) && echo "[ -e ${homedir}/.${dot_file} ] && mv -v ${homedir}/.${dot_file}{,.bak}"
((! DRY_RUN)) && [ -e ${homedir}/.${dot_file} ] && mv -v ${homedir}/.${dot_file}{,.bak}
((DEBUG||DRY_RUN)) && echo "ln -s $(_readlinkf ${dot_file}) ${homedir}/.${dot_file}"
if ((! DRY_RUN)); then
ln -s $(_readlinkf ${dot_file}) ${homedir}/${dot_file}
echo "((FORCE && DEBUG)) && [ -L "${homedir}/.${dot_file}" ] && [ "$(_readlinkf ${homedir}/.${dot_file})" != "$(_readlinkf ${dot_file})" ] && unlink ${homedir}/.${dot_file}"
((FORCE)) && [ -L "${homedir}/.${dot_file}" ] && [ "$(_readlinkf ${homedir}/.${dot_file})" != "$(_readlinkf ${dot_file})" ] && unlink ${homedir}/.${dot_file}
ln -s $(_readlinkf ${dot_file}) ${homedir}/.${dot_file}
if [ $? != 0 ]; then echo "ERROR: problem linking ${dot_file}"; else echo " linked file... [OK] " && ((++mod_count)); fi
fi
fi
Expand Down Expand Up @@ -156,6 +159,10 @@ main() {
shift
DEBUG=1
;;
--force)
shift
FORCE=1
;;
--dry-run)
shift
DRY_RUN=1
Expand Down

0 comments on commit a1fbacc

Please sign in to comment.