Skip to content

Commit

Permalink
completion/dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelicWizard committed Feb 23, 2022
1 parent 2528592 commit 1c2b0bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion clean_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ completion/available/consul.completion.bash
completion/available/crystal.completion.bash
completion/available/dart.completion.bash
completion/available/defaults.completion.bash
#completion/available/dirs.completion.bash
completion/available/dirs.completion.bash
completion/available/django.completion.bash
completion/available/dmidecode.completion.bash
completion/available/docker-machine.completion.bash
Expand Down
20 changes: 9 additions & 11 deletions completion/available/dirs.completion.bash
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#!/usr/bin/env bash
# Bash completion support for the 'dirs' plugin (commands G, R).
# shellcheck shell=bash
about-completion "Bash completion support for the 'dirs' plugin (commands G, R)."

_dirs-complete() {
local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}"
function _dirs-complete() {
# parse all defined shortcuts ${BASH_IT_DIRS_BKS}
if [[ -s "${BASH_IT_DIRS_BKS:-/dev/null}" ]]; then
IFS=$'\n' read -d '' -ra COMPREPLY < <(grep -v '^#' "${BASH_IT_DIRS_BKS?}" | sed -e 's/\(.*\)=.*/\1/')
fi

# parse all defined shortcuts from ~/.dirs
if [ -r "$HOME/.dirs" ]; then
COMPREPLY=($(compgen -W "$(grep -v '^#' ~/.dirs | sed -e 's/\(.*\)=.*/\1/')" -- ${CURRENT_PROMPT}) )
fi

return 0
return 0
}

complete -o default -o nospace -F _dirs-complete G R
complete -o default -o nospace -F _dirs-complete -X '!&*' G R

0 comments on commit 1c2b0bc

Please sign in to comment.