Skip to content

Commit

Permalink
Support completion for bash functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Chi-teck authored and fabpot committed Nov 19, 2022
1 parent dcda527 commit f2dd071
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Resources/completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ _sf_{{ COMMAND_NAME }}() {
local sf_cmd="${COMP_WORDS[0]}"

# for an alias, get the real script behind it
if [[ $(type -t $sf_cmd) == "alias" ]]; then
sf_cmd_type=$(type -t $sf_cmd)
if [[ $sf_cmd_type == "alias" ]]; then
sf_cmd=$(alias $sf_cmd | sed -E "s/alias $sf_cmd='(.*)'/\1/")
else
elif [[ $sf_cmd_type == "file" ]]; then
sf_cmd=$(type -p $sf_cmd)
fi

if [ ! -x "$sf_cmd" ]; then
if [[ $sf_cmd_type != "function" && ! -x $sf_cmd ]]; then
return 1
fi

Expand Down

0 comments on commit f2dd071

Please sign in to comment.