aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-07-30 01:17:09 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-07-30 02:09:30 +1200
commit4cbbd121c012b3962f12fdff0f1820c3b8636a44 (patch)
tree00149270df365ed0b7a1b9e9f4922fe7d5a80eb3
parent23a05c1d2d7210f9dbfb6682dcdb0e59deb21455 (diff)
downloaddotfiles-4cbbd121c012b3962f12fdff0f1820c3b8636a44.tar.gz
Move bash completion setup into separate dir
-rw-r--r--Makefile4
-rw-r--r--bash/bash_completion.d/bash.bash (renamed from bash/bashrc.d/completion.bash)0
-rw-r--r--bash/bash_completion.d/bd.bash22
-rw-r--r--bash/bash_completion.d/ftp.bash (renamed from bash/bashrc.d/ftp.bash)0
-rw-r--r--bash/bash_completion.d/git.bash (renamed from bash/bashrc.d/git.bash)0
-rw-r--r--bash/bash_completion.d/gpg.bash17
-rw-r--r--bash/bash_completion.d/keep.bash2
-rw-r--r--bash/bash_completion.d/make.bash (renamed from bash/bashrc.d/make.bash)0
-rw-r--r--bash/bash_completion.d/man.bash (renamed from bash/bashrc.d/man.bash)0
-rw-r--r--bash/bash_completion.d/mkcd.bash1
-rw-r--r--bash/bash_completion.d/mysql.bash34
-rw-r--r--bash/bash_completion.d/pass.bash (renamed from bash/bashrc.d/pass.bash)0
-rw-r--r--bash/bash_completion.d/path.bash60
-rw-r--r--bash/bash_completion.d/prompt.bash2
-rw-r--r--bash/bash_completion.d/sd.bash39
-rw-r--r--bash/bash_completion.d/ssh.bash (renamed from bash/bashrc.d/ssh.bash)0
-rw-r--r--bash/bash_completion.d/td.bash (renamed from bash/bashrc.d/td.bash)0
-rw-r--r--bash/bash_completion.d/ud.bash28
-rw-r--r--bash/bash_completion.d/vared.bash1
-rw-r--r--bash/bash_completion.d/vis.bash (renamed from bash/bashrc.d/vis.bash)0
-rw-r--r--bash/bash_completion.d/vr.bash1
-rw-r--r--bash/bashrc10
-rw-r--r--bash/bashrc.d/bd.bash23
-rw-r--r--bash/bashrc.d/cf.bash1
-rw-r--r--bash/bashrc.d/gpg.bash18
-rw-r--r--bash/bashrc.d/keep.bash3
-rw-r--r--bash/bashrc.d/mkcd.bash1
-rw-r--r--bash/bashrc.d/mysql.bash35
-rw-r--r--bash/bashrc.d/path.bash61
-rw-r--r--bash/bashrc.d/prompt.bash3
-rw-r--r--bash/bashrc.d/sd.bash42
-rw-r--r--bash/bashrc.d/ud.bash29
-rw-r--r--bash/bashrc.d/vared.bash1
-rw-r--r--bash/bashrc.d/vr.bash1
34 files changed, 221 insertions, 218 deletions
diff --git a/Makefile b/Makefile
index 06b87ef6..c620e785 100644
--- a/Makefile
+++ b/Makefile
@@ -114,13 +114,15 @@ install-bash : test-bash
install -m 0755 -d -- \
"$(HOME)"/.config \
"$(HOME)"/.bashrc.d \
- "$(HOME)"/.bash_profile.d
+ "$(HOME)"/.bash_profile.d \
+ "$(HOME)"/.bash_completion.d
install -pm 0644 -- bash/bashrc "$(HOME)"/.bashrc
install -pm 0644 -- bash/bashrc.d/* "$(HOME)"/.bashrc.d
install -pm 0644 -- bash/bash_profile "$(HOME)"/.bash_profile
install -pm 0644 -- bash/bash_profile.d/* "$(HOME)"/.bash_profile.d
install -pm 0644 -- bash/bash_logout "$(HOME)"/.bash_logout
install -pm 0644 -- bash/bash_completion "$(HOME)"/.config/bash_completion
+ install -pm 0644 -- bash/bash_completion.d/* "$(HOME)"/.bash_completion.d
install-bin : test-bin install-bin-man
install -m 0755 -d -- "$(HOME)"/.local/bin
diff --git a/bash/bashrc.d/completion.bash b/bash/bash_completion.d/bash.bash
index 5d944b9b..5d944b9b 100644
--- a/bash/bashrc.d/completion.bash
+++ b/bash/bash_completion.d/bash.bash
diff --git a/bash/bash_completion.d/bd.bash b/bash/bash_completion.d/bd.bash
new file mode 100644
index 00000000..68589dff
--- /dev/null
+++ b/bash/bash_completion.d/bd.bash
@@ -0,0 +1,22 @@
+# Completion setup for bd
+_bd() {
+
+ # Only makes sense for the first argument
+ ((COMP_CWORD == 1)) || return 1
+
+ # Build a list of dirnames in $PWD
+ local -a dirnames
+ IFS=/ read -d '' -a dirnames < <(printf '%s\0' "${PWD#/}")
+
+ # Remove the last element in the array (the current directory)
+ ((${#dirnames[@]})) || return 1
+ dirnames=("${dirnames[@]:0:"$((${#dirnames[@]}-1))"}")
+
+ # Add the matching dirnames to the reply
+ local dirname
+ for dirname in "${dirnames[@]}" ; do
+ [[ $dirname == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue
+ COMPREPLY=("${COMPREPLY[@]}" "$(printf %q "$dirname")")
+ done
+}
+complete -F _bd bd
diff --git a/bash/bashrc.d/ftp.bash b/bash/bash_completion.d/ftp.bash
index 5770f137..5770f137 100644
--- a/bash/bashrc.d/ftp.bash
+++ b/bash/bash_completion.d/ftp.bash
diff --git a/bash/bashrc.d/git.bash b/bash/bash_completion.d/git.bash
index 496712ae..496712ae 100644
--- a/bash/bashrc.d/git.bash
+++ b/bash/bash_completion.d/git.bash
diff --git a/bash/bash_completion.d/gpg.bash b/bash/bash_completion.d/gpg.bash
new file mode 100644
index 00000000..c2f08415
--- /dev/null
+++ b/bash/bash_completion.d/gpg.bash
@@ -0,0 +1,17 @@
+# Completion for gpg with long options
+_gpg() {
+
+ # Bail if no gpg(1)
+ hash gpg 2>/dev/null || return 1
+
+ # Bail if not completing an option
+ [[ ${COMP_WORDS[COMP_CWORD]} == --* ]] || return 1
+
+ # Generate completion reply from gpg(1) options
+ local option
+ while read -r option ; do
+ [[ $option == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue
+ COMPREPLY[${#COMPREPLY[@]}]=$option
+ done < <(gpg --dump-options 2>/dev/null)
+}
+complete -F _gpg -o default gpg
diff --git a/bash/bash_completion.d/keep.bash b/bash/bash_completion.d/keep.bash
new file mode 100644
index 00000000..bfe5dd2f
--- /dev/null
+++ b/bash/bash_completion.d/keep.bash
@@ -0,0 +1,2 @@
+# Complete calls to keep with existing function names and variable names
+complete -A function -A variable keep
diff --git a/bash/bashrc.d/make.bash b/bash/bash_completion.d/make.bash
index ca209e8e..ca209e8e 100644
--- a/bash/bashrc.d/make.bash
+++ b/bash/bash_completion.d/make.bash
diff --git a/bash/bashrc.d/man.bash b/bash/bash_completion.d/man.bash
index f1762a01..f1762a01 100644
--- a/bash/bashrc.d/man.bash
+++ b/bash/bash_completion.d/man.bash
diff --git a/bash/bash_completion.d/mkcd.bash b/bash/bash_completion.d/mkcd.bash
new file mode 100644
index 00000000..0db967d8
--- /dev/null
+++ b/bash/bash_completion.d/mkcd.bash
@@ -0,0 +1 @@
+complete -A directory mkcd
diff --git a/bash/bash_completion.d/mysql.bash b/bash/bash_completion.d/mysql.bash
new file mode 100644
index 00000000..f64b6f32
--- /dev/null
+++ b/bash/bash_completion.d/mysql.bash
@@ -0,0 +1,34 @@
+# Completion setup for MySQL for configured databases
+_mysql() {
+
+ # Only makes sense for first argument
+ ((COMP_CWORD == 1)) || return 1
+
+ # Bail if directory doesn't exist
+ local dirname
+ dirname=$HOME/.mysql
+ [[ -d $dirname ]] || return 1
+
+ # Return the names of the .cnf files sans prefix as completions
+ local db
+ while IFS= read -rd '' db ; do
+ COMPREPLY[${#COMPREPLY[@]}]=$db
+ done < <(
+
+ # Set options so that globs expand correctly
+ shopt -s dotglob nullglob
+
+ # Collect all the config file names, strip off leading path and .cnf
+ local -a cnfs
+ cnfs=("$dirname"/"${COMP_WORDS[COMP_CWORD]}"*.cnf)
+ cnfs=("${cnfs[@]#"$dirname"/}")
+ cnfs=("${cnfs[@]%.cnf}")
+
+ # Bail if no files to prevent empty output
+ ((${#cnfs[@]})) || exit 1
+
+ # Print the conf names, null-delimited
+ printf '%q\0' "${cnfs[@]}"
+ )
+}
+complete -F _mysql -o default mysql
diff --git a/bash/bashrc.d/pass.bash b/bash/bash_completion.d/pass.bash
index 28941952..28941952 100644
--- a/bash/bashrc.d/pass.bash
+++ b/bash/bash_completion.d/pass.bash
diff --git a/bash/bash_completion.d/path.bash b/bash/bash_completion.d/path.bash
new file mode 100644
index 00000000..fd94b7c4
--- /dev/null
+++ b/bash/bash_completion.d/path.bash
@@ -0,0 +1,60 @@
+# Completion for path
+_path() {
+
+ # What to do depends on which word we're completing
+ if ((COMP_CWORD == 1)) ; then
+
+ # Complete operation as first word
+ local cmd
+ for cmd in help list insert append remove set check ; do
+ [[ $cmd == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue
+ COMPREPLY[${#COMPREPLY[@]}]=$cmd
+ done
+
+ # Complete with either directories or $PATH entries as all other words
+ else
+ case ${COMP_WORDS[1]} in
+
+ # Complete with a directory
+ insert|i|append|add|a|check|c|set|s)
+ local dirname
+ while IFS= read -rd '' dirname ; do
+ COMPREPLY[${#COMPREPLY[@]}]=$dirname
+ done < <(
+
+ # Set options to glob correctly
+ shopt -s dotglob nullglob
+
+ # Collect directory names, strip trailing slash
+ local -a dirnames
+ dirnames=("${COMP_WORDS[COMP_CWORD]}"*/)
+ dirnames=("${dirnames[@]%/}")
+
+ # Bail if no results to prevent empty output
+ ((${#dirnames[@]})) || exit 1
+
+ # Print results, quoted and null-delimited
+ printf '%q\0' "${dirnames[@]}"
+ )
+ ;;
+
+ # Complete with directories from PATH
+ remove|rm|r)
+ local -a promptarr
+ IFS=: read -d '' -a promptarr < <(printf '%s\0' "$PATH")
+ local part
+ for part in "${promptarr[@]}" ; do
+ [[ $part == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue
+ COMPREPLY[${#COMPREPLY[@]}]=$(printf '%q\0' "$part")
+ done
+ ;;
+
+ # No completion
+ *)
+ return 1
+ ;;
+ esac
+ fi
+}
+
+complete -F _path path
diff --git a/bash/bash_completion.d/prompt.bash b/bash/bash_completion.d/prompt.bash
new file mode 100644
index 00000000..b114b7bb
--- /dev/null
+++ b/bash/bash_completion.d/prompt.bash
@@ -0,0 +1,2 @@
+# Complete words
+complete -W 'on off git hg svn vcs ret job' prompt
diff --git a/bash/bash_completion.d/sd.bash b/bash/bash_completion.d/sd.bash
new file mode 100644
index 00000000..f8017591
--- /dev/null
+++ b/bash/bash_completion.d/sd.bash
@@ -0,0 +1,39 @@
+# Completion function for sd; any sibling directories, excluding the self
+_sd() {
+
+ # Only makes sense for the first argument
+ ((COMP_CWORD == 1)) || return 1
+
+ # Current directory can't be root directory
+ [[ $PWD != / ]] || return 1
+
+ # Build list of matching sibiling directories
+ while IFS= read -rd '' dirname ; do
+ COMPREPLY[${#COMPREPLY[@]}]=$dirname
+ done < <(
+
+ # Set options to glob correctly
+ shopt -s dotglob nullglob
+
+ # Collect directory names, strip leading ../ and trailing /
+ local -a dirnames
+ dirnames=(../"${COMP_WORDS[COMP_CWORD]}"*/)
+ dirnames=("${dirnames[@]#../}")
+ dirnames=("${dirnames[@]%/}")
+
+ # Iterate again, but exclude the current directory this time
+ local -a sibs
+ local dirname
+ for dirname in "${dirnames[@]}" ; do
+ [[ $dirname != "${PWD##*/}" ]] || continue
+ sibs[${#sibs[@]}]=$dirname
+ done
+
+ # Bail if no results to prevent empty output
+ ((${#sibs[@]})) || exit 1
+
+ # Print results, null-delimited
+ printf '%q\0' "${sibs[@]}"
+ )
+}
+complete -F _sd sd
diff --git a/bash/bashrc.d/ssh.bash b/bash/bash_completion.d/ssh.bash
index bbb9b246..bbb9b246 100644
--- a/bash/bashrc.d/ssh.bash
+++ b/bash/bash_completion.d/ssh.bash
diff --git a/bash/bashrc.d/td.bash b/bash/bash_completion.d/td.bash
index ffb9c973..ffb9c973 100644
--- a/bash/bashrc.d/td.bash
+++ b/bash/bash_completion.d/td.bash
diff --git a/bash/bash_completion.d/ud.bash b/bash/bash_completion.d/ud.bash
new file mode 100644
index 00000000..47171b78
--- /dev/null
+++ b/bash/bash_completion.d/ud.bash
@@ -0,0 +1,28 @@
+# Completion setup for ud
+_ud() {
+
+ # Only makes sense for the second argument
+ ((COMP_CWORD == 2)) || return 1
+
+ # Iterate through directories, null-separated, add them to completions
+ local dirname
+ while IFS= read -rd '' dirname ; do
+ COMPREPLY[${#COMPREPLY[@]}]=$dirname
+ done < <(
+
+ # Set options to glob correctly
+ shopt -s dotglob nullglob
+
+ # Collect directory names, strip trailing slashes
+ local -a dirnames
+ dirnames=("${COMP_WORDS[COMP_CWORD]}"*/)
+ dirnames=("${dirnames[@]%/}")
+
+ # Bail if no results to prevent empty output
+ ((${#dirnames[@]})) || exit 1
+
+ # Print results null-delimited
+ printf '%s\0' "${dirnames[@]}"
+ )
+}
+complete -F _ud -o filenames ud
diff --git a/bash/bash_completion.d/vared.bash b/bash/bash_completion.d/vared.bash
new file mode 100644
index 00000000..ea8cefd1
--- /dev/null
+++ b/bash/bash_completion.d/vared.bash
@@ -0,0 +1 @@
+complete -A variable vared
diff --git a/bash/bashrc.d/vis.bash b/bash/bash_completion.d/vis.bash
index f84cb702..f84cb702 100644
--- a/bash/bashrc.d/vis.bash
+++ b/bash/bash_completion.d/vis.bash
diff --git a/bash/bash_completion.d/vr.bash b/bash/bash_completion.d/vr.bash
new file mode 100644
index 00000000..2d5120f0
--- /dev/null
+++ b/bash/bash_completion.d/vr.bash
@@ -0,0 +1 @@
+complete -A directory vr
diff --git a/bash/bashrc b/bash/bashrc
index facdd7eb..7338b64c 100644
--- a/bash/bashrc
+++ b/bash/bashrc
@@ -114,3 +114,13 @@ if [[ -d $HOME/.bashrc.d ]] ; then
done
unset -v bashrc
fi
+
+# Load any completion files
+if [[ -d $HOME/.bash_completion.d ]] ; then
+ for bashcmp in "$HOME"/.bash_completion.d/*.bash ; do
+ if [[ -e $bashcmp ]] ; then
+ source "$bashcmp"
+ fi
+ done
+ unset -v bashcmp
+fi
diff --git a/bash/bashrc.d/bd.bash b/bash/bashrc.d/bd.bash
index b7fbe77e..23a2d380 100644
--- a/bash/bashrc.d/bd.bash
+++ b/bash/bashrc.d/bd.bash
@@ -76,26 +76,3 @@ bd() {
# Try to change into the determined directory
builtin cd "${opts[@]}" -- "$dirname"
}
-
-# Completion setup for bd
-_bd() {
-
- # Only makes sense for the first argument
- ((COMP_CWORD == 1)) || return 1
-
- # Build a list of dirnames in $PWD
- local -a dirnames
- IFS=/ read -d '' -a dirnames < <(printf '%s\0' "${PWD#/}")
-
- # Remove the last element in the array (the current directory)
- ((${#dirnames[@]})) || return 1
- dirnames=("${dirnames[@]:0:"$((${#dirnames[@]}-1))"}")
-
- # Add the matching dirnames to the reply
- local dirname
- for dirname in "${dirnames[@]}" ; do
- [[ $dirname == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue
- COMPREPLY=("${COMPREPLY[@]}" "$(printf %q "$dirname")")
- done
-}
-complete -F _bd bd
diff --git a/bash/bashrc.d/cf.bash b/bash/bashrc.d/cf.bash
index 9d6db7dd..50308fa3 100644
--- a/bash/bashrc.d/cf.bash
+++ b/bash/bashrc.d/cf.bash
@@ -27,4 +27,3 @@ cf() {
printf '%u\t%s\n' "${#files[@]}" "$dirname"
)
}
-complete -A directory cf
diff --git a/bash/bashrc.d/gpg.bash b/bash/bashrc.d/gpg.bash
index 28c5b722..62d123ea 100644
--- a/bash/bashrc.d/gpg.bash
+++ b/bash/bashrc.d/gpg.bash
@@ -8,21 +8,3 @@ gpg() {
esac
command gpg "$@"
}
-
-# Completion for gpg with long options
-_gpg() {
-
- # Bail if no gpg(1)
- hash gpg 2>/dev/null || return 1
-
- # Bail if not completing an option
- [[ ${COMP_WORDS[COMP_CWORD]} == --* ]] || return 1
-
- # Generate completion reply from gpg(1) options
- local option
- while read -r option ; do
- [[ $option == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue
- COMPREPLY[${#COMPREPLY[@]}]=$option
- done < <(gpg --dump-options 2>/dev/null)
-}
-complete -F _gpg -o default gpg
diff --git a/bash/bashrc.d/keep.bash b/bash/bashrc.d/keep.bash
index 585dd189..b1c8bea4 100644
--- a/bash/bashrc.d/keep.bash
+++ b/bash/bashrc.d/keep.bash
@@ -144,9 +144,6 @@ EOF
)
}
-# Complete calls to keep with existing function names and variable names
-complete -A function -A variable keep
-
# Load any existing scripts in bashkeep
if [[ -d ${BASHKEEP:-"$HOME"/.bashkeep.d} ]] ; then
for bashkeep in "${BASHKEEP:-"$HOME"/.bashkeep.d}"/*.bash ; do
diff --git a/bash/bashrc.d/mkcd.bash b/bash/bashrc.d/mkcd.bash
index 2d596641..6342d4a6 100644
--- a/bash/bashrc.d/mkcd.bash
+++ b/bash/bashrc.d/mkcd.bash
@@ -2,4 +2,3 @@
mkcd() {
mkdir -p -- "$1" && builtin cd -- "$1"
}
-complete -A directory mkcd
diff --git a/bash/bashrc.d/mysql.bash b/bash/bashrc.d/mysql.bash
index dd9ffe73..0d5ddb86 100644
--- a/bash/bashrc.d/mysql.bash
+++ b/bash/bashrc.d/mysql.bash
@@ -19,38 +19,3 @@ mysql() {
fi
command mysql "$@"
}
-
-# Completion setup for MySQL for configured databases
-_mysql() {
-
- # Only makes sense for first argument
- ((COMP_CWORD == 1)) || return 1
-
- # Bail if directory doesn't exist
- local dirname
- dirname=$HOME/.mysql
- [[ -d $dirname ]] || return 1
-
- # Return the names of the .cnf files sans prefix as completions
- local db
- while IFS= read -rd '' db ; do
- COMPREPLY[${#COMPREPLY[@]}]=$db
- done < <(
-
- # Set options so that globs expand correctly
- shopt -s dotglob nullglob
-
- # Collect all the config file names, strip off leading path and .cnf
- local -a cnfs
- cnfs=("$dirname"/"${COMP_WORDS[COMP_CWORD]}"*.cnf)
- cnfs=("${cnfs[@]#"$dirname"/}")
- cnfs=("${cnfs[@]%.cnf}")
-
- # Bail if no files to prevent empty output
- ((${#cnfs[@]})) || exit 1
-
- # Print the conf names, null-delimited
- printf '%q\0' "${cnfs[@]}"
- )
-}
-complete -F _mysql -o default mysql
diff --git a/bash/bashrc.d/path.bash b/bash/bashrc.d/path.bash
index e16e6a4a..61bf73c0 100644
--- a/bash/bashrc.d/path.bash
+++ b/bash/bashrc.d/path.bash
@@ -178,64 +178,3 @@ EOF
;;
esac
}
-
-# Completion for path
-_path() {
-
- # What to do depends on which word we're completing
- if ((COMP_CWORD == 1)) ; then
-
- # Complete operation as first word
- local cmd
- for cmd in help list insert append remove set check ; do
- [[ $cmd == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue
- COMPREPLY[${#COMPREPLY[@]}]=$cmd
- done
-
- # Complete with either directories or $PATH entries as all other words
- else
- case ${COMP_WORDS[1]} in
-
- # Complete with a directory
- insert|i|append|add|a|check|c|set|s)
- local dirname
- while IFS= read -rd '' dirname ; do
- COMPREPLY[${#COMPREPLY[@]}]=$dirname
- done < <(
-
- # Set options to glob correctly
- shopt -s dotglob nullglob
-
- # Collect directory names, strip trailing slash
- local -a dirnames
- dirnames=("${COMP_WORDS[COMP_CWORD]}"*/)
- dirnames=("${dirnames[@]%/}")
-
- # Bail if no results to prevent empty output
- ((${#dirnames[@]})) || exit 1
-
- # Print results, quoted and null-delimited
- printf '%q\0' "${dirnames[@]}"
- )
- ;;
-
- # Complete with directories from PATH
- remove|rm|r)
- local -a promptarr
- IFS=: read -d '' -a promptarr < <(printf '%s\0' "$PATH")
- local part
- for part in "${promptarr[@]}" ; do
- [[ $part == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue
- COMPREPLY[${#COMPREPLY[@]}]=$(printf '%q\0' "$part")
- done
- ;;
-
- # No completion
- *)
- return 1
- ;;
- esac
- fi
-}
-
-complete -F _path path
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash
index b6847a92..bef80733 100644
--- a/bash/bashrc.d/prompt.bash
+++ b/bash/bashrc.d/prompt.bash
@@ -280,8 +280,5 @@ prompt() {
esac
}
-# Complete words
-complete -W 'on off git hg svn vcs ret job' prompt
-
# Start with full-fledged prompt
prompt on
diff --git a/bash/bashrc.d/sd.bash b/bash/bashrc.d/sd.bash
index 9d1063d6..ad4a0deb 100644
--- a/bash/bashrc.d/sd.bash
+++ b/bash/bashrc.d/sd.bash
@@ -30,7 +30,7 @@
# $ pwd
# /tmp/tmp.ZSunna5Eup/a
#
-# Seems to work for symbolic links. Completion included.
+# Seems to work for symbolic links.
#
sd() {
@@ -107,43 +107,3 @@ sd() {
# Try to change into the determined directory
builtin cd "${opts[@]}" ../"$dirname"
}
-
-# Completion function for sd; any sibling directories, excluding the self
-_sd() {
-
- # Only makes sense for the first argument
- ((COMP_CWORD == 1)) || return 1
-
- # Current directory can't be root directory
- [[ $PWD != / ]] || return 1
-
- # Build list of matching sibiling directories
- while IFS= read -rd '' dirname ; do
- COMPREPLY[${#COMPREPLY[@]}]=$dirname
- done < <(
-
- # Set options to glob correctly
- shopt -s dotglob nullglob
-
- # Collect directory names, strip leading ../ and trailing /
- local -a dirnames
- dirnames=(../"${COMP_WORDS[COMP_CWORD]}"*/)
- dirnames=("${dirnames[@]#../}")
- dirnames=("${dirnames[@]%/}")
-
- # Iterate again, but exclude the current directory this time
- local -a sibs
- local dirname
- for dirname in "${dirnames[@]}" ; do
- [[ $dirname != "${PWD##*/}" ]] || continue
- sibs[${#sibs[@]}]=$dirname
- done
-
- # Bail if no results to prevent empty output
- ((${#sibs[@]})) || exit 1
-
- # Print results, null-delimited
- printf '%q\0' "${sibs[@]}"
- )
-}
-complete -F _sd sd
diff --git a/bash/bashrc.d/ud.bash b/bash/bashrc.d/ud.bash
index a1792968..e23de1fa 100644
--- a/bash/bashrc.d/ud.bash
+++ b/bash/bashrc.d/ud.bash
@@ -48,32 +48,3 @@ ud() {
# Try to change into it
cd "${opts[@]}" -- "$dirname"
}
-
-# Completion setup for ud
-_ud() {
-
- # Only makes sense for the second argument
- ((COMP_CWORD == 2)) || return 1
-
- # Iterate through directories, null-separated, add them to completions
- local dirname
- while IFS= read -rd '' dirname ; do
- COMPREPLY[${#COMPREPLY[@]}]=$dirname
- done < <(
-
- # Set options to glob correctly
- shopt -s dotglob nullglob
-
- # Collect directory names, strip trailing slashes
- local -a dirnames
- dirnames=("${COMP_WORDS[COMP_CWORD]}"*/)
- dirnames=("${dirnames[@]%/}")
-
- # Bail if no results to prevent empty output
- ((${#dirnames[@]})) || exit 1
-
- # Print results null-delimited
- printf '%s\0' "${dirnames[@]}"
- )
-}
-complete -F _ud -o filenames ud
diff --git a/bash/bashrc.d/vared.bash b/bash/bashrc.d/vared.bash
index 510631ca..66250a3f 100644
--- a/bash/bashrc.d/vared.bash
+++ b/bash/bashrc.d/vared.bash
@@ -28,4 +28,3 @@ vared() {
IFS= read -e -i "${!name}" -p "${prompt:-"$name"=}" -r -- "$name"
done
}
-complete -A variable vared
diff --git a/bash/bashrc.d/vr.bash b/bash/bashrc.d/vr.bash
index 04a86835..adabb395 100644
--- a/bash/bashrc.d/vr.bash
+++ b/bash/bashrc.d/vr.bash
@@ -57,4 +57,3 @@ vr() {
"$FUNCNAME" >&2
return 1
}
-complete -A directory vr