Results 1 to 1 of 1
Trying to write an ssh autocomplete. I want an selection such as the following to be converted to the one after ->. After much googling couldn't find any how to ...
- 10-13-2010 #1Just Joined!
- Join Date
- Oct 2010
- Posts
- 1
bash autocomplete, replacement of currently generated command
Trying to write an ssh autocomplete. I want an selection such as the following to be converted to the one after ->. After much googling couldn't find any how to replace already generated words.
ex.
ssh stage 1 -> ssh usstageserver001
ssh prod 3 -> ssh usprodserver003
In short auto-completion of 'ssh env machine' works. I want to replace 'ssh env machine' with 'ssh env-machine-in-one-word'.
Code:_ssh() { local cur prev opts COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" opts="stage prod" case "${prev}" in stage) COMPREPLY=( $(compgen -W "1 2" -- ${cur}) ) return 0; ;; prod) COMPREPLY=( $(compgen -W "1 2 3 4 5" -- ${cur}) ) return 0 ;; *) ;; esac COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) } complete -F _ssh ssh


Reply With Quote