mirror of
https://github.com/alexpasmantier/television.git
synced 2025-06-06 03:25:23 +00:00

The call ensures that the prompt restores properly and looks correct after using television. This fixes #300 for me locally.
27 lines
755 B
Fish
27 lines
755 B
Fish
function tv_smart_autocomplete
|
|
set -l current_prompt (commandline -cp)
|
|
|
|
set -l output (tv --autocomplete-prompt "$current_prompt")
|
|
|
|
if test -n "$output"
|
|
# add a space if the prompt does not end with one (unless the prompt is an implicit cd, e.g. '\.')
|
|
string match -r '.*( |./)$' -- "$current_prompt" || set current_prompt "$current_prompt "
|
|
commandline -r "$current_prompt$output"
|
|
commandline -f repaint
|
|
end
|
|
end
|
|
|
|
function tv_shell_history
|
|
set -l current_prompt (commandline -cp)
|
|
|
|
set -l output (tv fish-history --input "$current_prompt")
|
|
|
|
if test -n "$output"
|
|
commandline -r "$output"
|
|
commandline -f repaint
|
|
end
|
|
end
|
|
|
|
bind \ct tv_smart_autocomplete
|
|
bind \cr tv_shell_history
|