mirror of
https://github.com/alexpasmantier/television.git
synced 2025-06-06 03:25:23 +00:00
feat(shell): shell integration support for fish (#186)
This commit is contained in:
parent
7614fbc653
commit
b49a06997b
@ -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'"
|
||||
|
||||
|
22
crates/television-utils/shell/completion.fish
Normal file
22
crates/television-utils/shell/completion.fish
Normal 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
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user