chore(integrations): zpipe alias (#3210)
* chore(completions): zpipe alias * chore(integrations): zpipe alias
This commit is contained in:
parent
58b13babbc
commit
ec6d627b06
7 changed files with 56 additions and 2 deletions
|
|
@ -667,3 +667,23 @@ fn generate_unique_session_name() -> String {
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn list_aliases(opts: CliArgs) {
|
||||||
|
let (config, _layout, _config_options, _config_without_layout, _config_options_without_layout) =
|
||||||
|
match Setup::from_cli_args(&opts) {
|
||||||
|
Ok(results) => results,
|
||||||
|
Err(e) => {
|
||||||
|
if let ConfigError::KdlError(error) = e {
|
||||||
|
let report: Report = error.into();
|
||||||
|
eprintln!("{:?}", report);
|
||||||
|
} else {
|
||||||
|
eprintln!("{}", e);
|
||||||
|
}
|
||||||
|
process::exit(1);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
for alias in config.plugins.list() {
|
||||||
|
println!("{}", alias);
|
||||||
|
}
|
||||||
|
process::exit(0);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,8 @@ fn main() {
|
||||||
})) = opts.command
|
})) = opts.command
|
||||||
{
|
{
|
||||||
commands::list_sessions(no_formatting, short);
|
commands::list_sessions(no_formatting, short);
|
||||||
|
} else if let Some(Command::Sessions(Sessions::ListAliases)) = opts.command {
|
||||||
|
commands::list_aliases(opts);
|
||||||
} else if let Some(Command::Sessions(Sessions::KillAllSessions { yes })) = opts.command {
|
} else if let Some(Command::Sessions(Sessions::KillAllSessions { yes })) = opts.command {
|
||||||
commands::kill_all_sessions(yes);
|
commands::kill_all_sessions(yes);
|
||||||
} else if let Some(Command::Sessions(Sessions::KillSession { ref target_session })) =
|
} else if let Some(Command::Sessions(Sessions::KillSession { ref target_session })) =
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,10 @@ function zr () { zellij run --name "$*" -- bash -ic "$*";}
|
||||||
function zrf () { zellij run --name "$*" --floating -- bash -ic "$*";}
|
function zrf () { zellij run --name "$*" --floating -- bash -ic "$*";}
|
||||||
function ze () { zellij edit "$*";}
|
function ze () { zellij edit "$*";}
|
||||||
function zef () { zellij edit --floating "$*";}
|
function zef () { zellij edit --floating "$*";}
|
||||||
|
function zpipe () {
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
zellij pipe;
|
||||||
|
else
|
||||||
|
zellij pipe -p $1;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,3 +18,16 @@ end
|
||||||
function zef
|
function zef
|
||||||
command zellij edit --floating $argv
|
command zellij edit --floating $argv
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# the zpipe alias and its completions
|
||||||
|
function __fish_complete_aliases
|
||||||
|
zellij list-aliases 2>/dev/null
|
||||||
|
end
|
||||||
|
function zpipe
|
||||||
|
if count $argv > /dev/null
|
||||||
|
command zellij pipe -p $argv
|
||||||
|
else
|
||||||
|
command zellij pipe
|
||||||
|
end
|
||||||
|
end
|
||||||
|
complete -c zpipe -f -a "(__fish_complete_aliases)" -d "Zpipes"
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,10 @@ function zr () { zellij run --name "$*" -- zsh -ic "$*";}
|
||||||
function zrf () { zellij run --name "$*" --floating -- zsh -ic "$*";}
|
function zrf () { zellij run --name "$*" --floating -- zsh -ic "$*";}
|
||||||
function ze () { zellij edit "$*";}
|
function ze () { zellij edit "$*";}
|
||||||
function zef () { zellij edit --floating "$*";}
|
function zef () { zellij edit --floating "$*";}
|
||||||
|
function zpipe () {
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
/home/aram/code/zellij/target/dev-opt/zellij pipe;
|
||||||
|
else
|
||||||
|
/home/aram/code/zellij/target/dev-opt/zellij pipe -p $1;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,9 @@ pub enum Sessions {
|
||||||
#[clap(short, long, value_parser, takes_value(false), default_value("false"))]
|
#[clap(short, long, value_parser, takes_value(false), default_value("false"))]
|
||||||
short: bool,
|
short: bool,
|
||||||
},
|
},
|
||||||
|
/// List existing plugin aliases
|
||||||
|
#[clap(visible_alias = "la")]
|
||||||
|
ListAliases,
|
||||||
/// Attach to a session
|
/// Attach to a session
|
||||||
#[clap(visible_alias = "a")]
|
#[clap(visible_alias = "a")]
|
||||||
Attach {
|
Attach {
|
||||||
|
|
@ -231,7 +233,7 @@ pub enum Sessions {
|
||||||
height: Option<String>,
|
height: Option<String>,
|
||||||
},
|
},
|
||||||
/// Load a plugin
|
/// Load a plugin
|
||||||
#[clap(visible_alias = "r")]
|
#[clap(visible_alias = "p")]
|
||||||
Plugin {
|
Plugin {
|
||||||
/// Plugin URL, can either start with http(s), file: or zellij:
|
/// Plugin URL, can either start with http(s), file: or zellij:
|
||||||
#[clap(last(true), required(true))]
|
#[clap(last(true), required(true))]
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ impl PluginAliases {
|
||||||
pub fn from_data(aliases: BTreeMap<String, RunPlugin>) -> Self {
|
pub fn from_data(aliases: BTreeMap<String, RunPlugin>) -> Self {
|
||||||
PluginAliases { aliases }
|
PluginAliases { aliases }
|
||||||
}
|
}
|
||||||
|
pub fn list(&self) -> Vec<String> {
|
||||||
|
self.aliases.keys().cloned().collect()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Plugin metadata
|
/// Plugin metadata
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue