Skip to content

Commit df5ff34

Browse files
committed
Add zqs-compdef-as helper script
Add helper function to make it easier to copy compdefs from one command to another. Signed-off-by: Joe Block <[email protected]>
1 parent 3248398 commit df5ff34

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

zsh/.zshrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@ function can_haz() {
2929
which "$@" > /dev/null 2>&1
3030
}
3131

32+
function zqs-compdef-as() {
33+
if [ $# == 0 ]; then
34+
echo "Makes it simpler to use one command's completions for another command too"
35+
echo
36+
echo "Usage: zqs-compdef-as sourcecommand target"
37+
echo
38+
echo "Example: To make z.lua use the same completions as cd, run"
39+
echo
40+
echo "zqs-compdef-as cd _zlua"
41+
fi
42+
if (($+_comps[$1])); then
43+
compdef $_comps[$1] ${^@[2,-1]}=$1
44+
else
45+
echo "Could not find a compdef for $1"
46+
fi
47+
}
48+
3249
function zqs-debug() {
3350
if [[ -f ${ZDOTDIR:-$HOME}/.zqs-debug-mode ]]; then
3451
echo $@

0 commit comments

Comments
 (0)