Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bash completion script #55

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions contrib/abduco_completion.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

function _abduco() {
case $2 in
-*) # Option
COMPREPLY=($(compgen -W ' \
-n -nf \
-c -cf -cr \
-f -fn -fc -fcr \
-A -Ar \
-a -ar \
-l -lr \
-r -rc -rcf -rA -ra -rl \
-e -e^ \
-v \
' -- $2))
;;
*) # Session
local sessions=$(abduco | tail -n+2 | cut -f 3)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The session name is in the third column for the latest release (v0.6) but on the master branch it's in the fourth column. awk '{print $NF}' (=last column) works for both versions:

Suggested change
local sessions=$(abduco | tail -n+2 | cut -f 3)
local sessions=$(abduco | tail -n+2 | awk '{print $NF}')

COMPREPLY=($(compgen -W "$sessions" -- $2))
[ -n "$2" ] && compopt -o plusdirs
;;
esac
}

command -F _abduco abduco

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
command -F _abduco abduco
complete -F _abduco abduco