Open mjpitz opened 9 years ago
Great idea. I often find myself sshing into the remote hosts just to get the paths right which is a huge pain.
Worked this up really quick. One big bug with the way it handles the completion post : . Looked into it a little but didn't spend too much time on it. I also had another iteration where I was using -F instead of -C for the results but I think this one is a little cleaner (although not by much). I think the completion is trying to treat the : as a word separator
_remtail_complete() {
local word=${COMP_WORDS[COMP_CWORD]}
local completions="$(cat ~/.remtail_history | awk '{print $2}' | grep ^$word)"
COMPREPLY=( $(compgen -W "$completions" -- "$word") )
}
complete -F _remtail_complete remtail
There is value is rolling this into the javascript code. Then we can autocomplete command flags: https://github.com/NickCarneiro/remtail/commit/760c935bd5baa1f6c4afea4ecf596b1d2bf5f5f7
Not done, but you can see where it was going.
Thought about this a little bit, but I typically use this to tail the same files every couple of days. We should be able to add bash completion support by creating a history file and using it to auto-complete values that you've entered in the past.
Technical Details
Example The history file currently contains:
After executing the
remtail trillworks.com:/var/log/nginx/access.log
, the new history file would be:Not sure if the count is necessary as these will be auto complete values and as far as bash is concerned for the auto-complete, it would just use second part of the line anyway.