feat(shell): shell integration support for fish (#186)

This commit is contained in:
Alex Pasmantier 2024-12-30 17:50:45 +01:00 committed by GitHub
parent 7614fbc653
commit b49a06997b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 0 deletions

View File

@ -40,3 +40,8 @@ source_command = "tail -r $HOME/.zsh_history | cut -d\";\" -f 2-"
[[cable_channel]]
name = "bash-history"
source_command = "tail -r $HOME/.bash_history"
[[cable_channel]]
name = "fish-history"
source_command = "fish -c 'history'"

View File

@ -0,0 +1,22 @@
function tv_smart_autocomplete
set -l current_prompt (commandline -cp)
set -l output (tv --autocomplete-prompt "$current_prompt")
if test -n "$output"
commandline -r "$current_prompt$output"
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"
end
end
bind \ct tv_smart_autocomplete
bind \cr tv_shell_history

View File

@ -11,11 +11,13 @@ pub enum Shell {
const COMPLETION_ZSH: &str = include_str!("../shell/completion.zsh");
const COMPLETION_BASH: &str = include_str!("../shell/completion.bash");
const COMPLETION_FISH: &str = include_str!("../shell/completion.fish");
pub fn completion_script(shell: Shell) -> Result<&'static str> {
match shell {
Shell::Bash => Ok(COMPLETION_BASH),
Shell::Zsh => Ok(COMPLETION_ZSH),
Shell::Fish => Ok(COMPLETION_FISH),
_ => color_eyre::eyre::bail!(
"This shell is not yet supported: {:?}",
shell