the_earnest/dotfiles
removed unfinished recursive version of godir
Commit facb973b147f · The Earnest · 2026-11-19 12:40 +0000
Comments
No comments yet.
Diff
diff --git a/godir/godir.bash.recursive b/godir/godir.bash.recursive
deleted file mode 100644
--- a/godir/godir.bash.recursive
+++ /dev/null
@@ -1,122 +0,0 @@
-function f {
- FINDCMD="find"
- for i in "$@"; do
- FINDCMD+=" -iname '"
- FINDCMD+='*'"$i"'*'
- FINDCMD+=\'
- done
- echo FINDCMD=$FINDCMD
- eval "$FINDCMD"
-}
-
-function _g()
-{
- local ARG="$*"
-
- # case 4: must perform search
- CONFIG_FILE=~/gd.conf
- [[ -e "$CONFIG_FILE" ]] && source "$CONFIG_FILE"
- [[ -z $MAXDEPTH ]] && MAXDEPTH=2
-
- [[ -n $VERBOSE ]] && echo gd: searching subtree for \"$ARG\"
- [[ -n $VERBOSE ]] && echo gd: MAXDEPTH=$MAXDEPTH
-
- GD_PRUNE_FILE=~/gd.prune
- if [[ -e "$GD_PRUNE_FILE" ]]
- then
- cat "$GD_PRUNE_FILE" | while read LINE; do
- echo $LINE
- done
- fi
-
- TMPFILE="$TMPDIR"/find.tmp
- #find -maxdepth $MAXDEPTH -path './Android' -prune -o -type d -iname '*'"${ARG}"'*' -print >"$TMPFILE"
- [[ -n $VERBOSE ]] && echo gd: PRUNE_EXPR=$PRUNE_EXPR
- find -maxdepth $MAXDEPTH $PRUNE_EXPR -type d -iname '*'"${ARG}"'*' -print | sed -e 's/^\.\///' >"$TMPFILE"
- N=$(cat "$TMPFILE"|wc -l)
- if [[ $N -eq 0 ]]
- then
- echo gd: \"$ARG\" not found
- rm "$TMPFILE"
- return
- fi
-
- if [[ $N -gt 1 ]]
- then
- [[ -n $VERBOSE ]] && echo gd: $N directories found for \"$ARG\"
- cat -n "$TMPFILE"
-
- local PROMPT="choose 1-$N: "
- local NKEYSOPT="-n${#N}"
- local KEY
- read -n${#N} -p "$PROMPT" KEY
- # echo newline if necessary
- [[ ${#KEY} -eq ${#N} ]] && echo
-
- if [[ -z "$KEY" ]]; then
- [[ -n $VERBOSE ]] && echo "gd: no choice"
- rm $TMPFILE
- return
- fi
-
- if [[ ! "$KEY" =~ ^[0-9]+$ ]]
- then
- echo "gd: not a valid choice"
- rm $TMPFILE
- return
- fi
-
- # input is a number
- if [[ $KEY -lt 1 || $KEY -gt $N ]]; then
- echo "gd: not a valid choice"
- fi
-
- # get the chosen line from the tempfile
- local TARGET_DIR=$(sed -n -e "$KEY p" "$TMPFILE")
- cd "$TARGET_DIR"
- rm $TMPFILE
- return
- fi
-
- # if we get here, $N must be
- # 1
- TARGET_DIR=$(cat "$TMPFILE")
- [[ -n $VERBOSE ]] && echo gd: unique result: \"$TARGET_DIR\" - OK
- cd "$TARGET_DIR"
- rm "$TMPFILE"
-}
-
-function g() {
-
- if [[ "$1" == "-v" ]]; then
- local VERBOSE=verbose
- shift
- fi
-
- # case 1: invoked without args, go to home dir
- if [[ $# -eq 0 ]]; then
- [[ -n $VERBOSE ]] && echo gd: no argument, going to home dir
- cd
- return
- fi
-
- # treat all remaining args as a single string
- local ARG="$*"
-
- # case 2: arg ends with fwd slash; possibly user invoked word
- # completion; if it matches a direct subdir, use that, otherwise
- # error
- if [[ "${ARG: -1}" == '/' ]]; then
- if [[ -d "$ARG" ]]; then
- [[ -n $VERBOSE ]] && echo gd: \"$ARG\" is name of direct subdir - OK
- cd "$ARG"
- return
- else
- echo gd: error: direct subdir \"$ARG\" does not exist
- [[ -n $VERBOSE ]] && echo gd: remove the slash if you want to go to a directory with a name containing \"${ARG%%/}\"
- return
- fi
- fi
-
- _g "$ARG"
-}