Permalink
Browse files

smartcd_edit was moved to its own file in dbbacb4, remove from core l…

…ibrary
  • Loading branch information...
1 parent 328cd42 commit 42e7ab003e380eae570aa909ef909a6984756163 @cxreg committed Apr 8, 2012
Showing with 0 additions and 86 deletions.
  1. +0 −86 lib/core/smartcd
View
86 lib/core/smartcd
@@ -573,92 +573,6 @@ function _smartcd() {
fi
}
-function smartcd_edit() {
- # Invoke the users editor (or vi) on the relevant file
- local file="$1"
- case $file in
- bash_enter|bash_leave) local type=${file#bash_};;
- enter|leave) local type=$file; file="bash_$file";;
- *) echo "Usage: smartcd_edit ( bash_enter | bash_leave )"
- return
- ;;
- esac
-
- if [[ -f "$HOME/.smartcd$(pwd)/$file" ]]; then
- smartcd_upgrade_database
- fi
-
- local smartcd_dir="$HOME/.smartcd/scripts$(pwd)"
- if [[ ! -d "$smartcd_dir" ]]; then
- command mkdir -p "$smartcd_dir"
- fi
-
- # Edit the file if interactive, otherwise write standard input to it
- if [[ -t 0 ]]; then
- local tmpfile=$(mktemp /tmp/smartcd-edit.XXXXXX) line=
- local _old_ifs="$IFS"
- IFS=$'\n'
- if [[ -f "$smartcd_dir/$file" ]]; then
- while builtin read -r line; do
- case $line in
- # extremely hinky replacement here, very whitespace sensitive
- *"smartcd template run"*) local tmpl=${line##*template run }
- tmpl=${tmpl%% *}
- echo "$line" >> "$tmpfile"
- echo "$(smartcd template show_part $tmpl ${file#bash_})" >> "$tmpfile"
- ;;
- *) echo "$line" >> "$tmpfile";;
- esac
- done < "$smartcd_dir/$file"
- else
- if [[ $type == "enter" ]]; then
- local enter_usage=$(cat <<EOF
- Some examples are editing your \$PATH or creating
-# a temporary alias:
-#
-# autostash PATH=__PATH__/bin:\$PATH
-# autostash alias restart="service stop; sleep 1; service start"
-EOF
-)
- fi
- command cat > "$tmpfile" << EOF
-########################################################################
-# smartcd $type - $(pwd)
-#
-# This is a smartcd script. Commands you type will be run when you
-# $type this directory. The string __PATH__ will be replaced with
-# the current path.$enter_usage
-#
-# See http://smartcd.org for more ideas about what can be put here
-########################################################################
-EOF
- fi
- ${EDITOR:-vi} "$tmpfile"
- if [[ $? == 0 ]]; then
- echo -n > "$smartcd_dir/$file"
- if [[ -s "$tmpfile" ]]; then
- local writing=1
- while builtin read -r line; do
- case $line in
- "# begin smartcd template"*) writing=;;
- "# end smartcd template"*) writing=1;;
- *) if [[ -n $writing ]]; then echo "$line" >> "$smartcd_dir/$file"; fi;;
- esac
- done < "$tmpfile"
- fi
- fi
- IFS="$_old_ifs"
- rm "$tmpfile"
- else
- command cat > "$smartcd_dir/$file"
- fi
-
- if [[ -f "$smartcd_dir/$file" && ! -s "$smartcd_dir/$file" ]]; then
- # Delete any file that is left empty
- command rm "$smartcd_dir/$file"
- fi
-}
-
function _smartcd_hook() {
local cwd="$(pwd)"

0 comments on commit 42e7ab0

Please sign in to comment.