Update fzf location
[dotfiles] / .bash_compl
1 #!/bin/sh
2
3 # COMPREPLY: an array containing possible completions as a result of your function
4 # COMP_WORDS: an array containing individual command arguments typed so far
5 # COMP_CWORD: the index of the command argument containing the current cursor position
6 # COMP_LINE: the current command line
7
8 # if you want the current argument that you are trying to complete, you would index into the words array
9 # using: ${COMP_WORDS[COMP_CWORD]}.
10
11
12 # to complete jump
13 _completemarks() {
14 local curw=${COMP_WORDS[COMP_CWORD]}
15 local wordlist=$(find $MARKPATH -type l -printf "%f\n")
16 COMPREPLY=($(compgen -W '${wordlist[@]}' -- $curw))
17 return 0
18 } && complete -F _completemarks jump unmark
19
20 # to complete ssh-add with exisiting priv keys
21 _complete_ssh_add () {
22 local curw=${COMP_WORDS[COMP_CWORD]}
23 #local sshkeys=$(find $HOME/.ssh -type f -printf "%f\n" | grep 'id_' | grep -v '.pub$');
24 local sshkeys=$(find $HOME/.ssh -type f | grep --color 'id_' | grep $HOME'/.ssh/id_' | grep -v '.pub$');
25 COMPREPLY=($(compgen -W '${sshkeys[@]}' -- $curw))
26 return 0
27 } && complete -F _complete_ssh_add ssh-add
28
29
30
31 #Bash completion for ◲ desk
32 # https://raw.githubusercontent.com/jamesob/desk/master/shell_plugins/bash/desk
33 _desk() {
34 PREFIX="${DESK_DIR:-$HOME/.desk}"
35 DESKS="${DESK_DESKS_DIR:-$PREFIX/desks}"
36
37 cur=${COMP_WORDS[COMP_CWORD]}
38 prev=${COMP_WORDS[COMP_CWORD-1]}
39
40 case ${COMP_CWORD} in
41 1)
42 COMPREPLY=($(compgen -W "edit . go help init list ls version" ${cur}))
43 ;;
44 2)
45 case ${prev} in
46 edit|go|.)
47 if [[ -d $DESKS ]]; then
48 local desks=$(desk list | cut -d' ' -f1)
49 else
50 local desks=""
51 fi
52 COMPREPLY=( $(compgen -W "${desks}" -- ${cur}) )
53 ;;
54 esac
55 ;;
56 *)
57 COMPREPLY=()
58 ;;
59 esac
60 } && complete -F _desk desk