diff options
author | Aram Drevekenin <aram@poor.dev> | 2024-03-20 18:34:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-20 18:34:50 +0100 |
commit | ec6d627b06dac2aaf94b1e2f8e55b889986bcc08 (patch) | |
tree | af6d382a4c44027329384b25a704037bf867ae7f | |
parent | 58b13babbc6f8a68b710992ece8e8eb04c4d8069 (diff) |
chore(integrations): zpipe alias (#3210)
* chore(completions): zpipe alias
* chore(integrations): zpipe alias
-rw-r--r-- | src/commands.rs | 20 | ||||
-rw-r--r-- | src/main.rs | 2 | ||||
-rw-r--r-- | zellij-utils/assets/completions/comp.bash | 7 | ||||
-rw-r--r-- | zellij-utils/assets/completions/comp.fish | 13 | ||||
-rw-r--r-- | zellij-utils/assets/completions/comp.zsh | 7 | ||||
-rw-r--r-- | zellij-utils/src/cli.rs | 6 | ||||
-rw-r--r-- | zellij-utils/src/input/plugins.rs | 3 |
7 files changed, 56 insertions, 2 deletions
diff --git a/src/commands.rs b/src/commands.rs index cde96b127..f27f0c550 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -667,3 +667,23 @@ fn generate_unique_session_name() -> String { 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); +} diff --git a/src/main.rs b/src/main.rs index 2ae37e2c2..0f0d980b6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -170,6 +170,8 @@ fn main() { })) = opts.command { 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 { commands::kill_all_sessions(yes); } else if let Some(Command::Sessions(Sessions::KillSession { ref target_session })) = diff --git a/zellij-utils/assets/completions/comp.bash b/zellij-utils/assets/completions/comp.bash index 867468090..eed994393 100644 --- a/zellij-utils/assets/completions/comp.bash +++ b/zellij-utils/assets/completions/comp.bash @@ -2,3 +2,10 @@ function zr () { zellij run --name "$*" -- bash -ic "$*";} function zrf () { zellij run --name "$*" --floating -- bash -ic "$*";} function ze () { zellij edit "$*";} function zef () { zellij edit --floating "$*";} +function zpipe () { + if [ -z "$1" ]; then + zellij pipe; + else + zellij pipe -p $1; + fi +} diff --git a/zellij-utils/assets/completions/comp.fish b/zellij-utils/assets/completions/comp.fish index 853eda60c..20591edc9 100644 --- a/zellij-utils/assets/completions/comp.fish +++ b/zellij-utils/assets/completions/comp.fish @@ -18,3 +18,16 @@ end function zef command zellij edit --floating $argv 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" diff --git a/zellij-utils/assets/completions/comp.zsh b/zellij-utils/assets/completions/comp.zsh index d9c737651..48c51d16a 100644 --- a/zellij-utils/assets/completions/comp.zsh +++ b/zellij-utils/assets/completions/comp.zsh @@ -2,3 +2,10 @@ function zr () { zellij run --name "$*" -- zsh -ic "$*";} function zrf () { zellij run --name "$*" --floating -- zsh -ic "$*";} function ze () { zellij edit "$*";} 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 +} diff --git a/zellij-utils/src/cli.rs b/zellij-utils/src/cli.rs index e5b65d394..3d30bb391 100644 --- a/zellij-utils/src/cli.rs +++ b/zellij-utils/src/cli.rs @@ -107,7 +107,9 @@ pub enum Sessions { #[clap(short, long, value_parser, takes_value(false), default_value("false"))] short: bool, }, - + /// List existing plugin aliases + #[clap(visible_alias = "la")] + ListAliases, /// Attach to a session #[clap(visible_alias = "a")] Attach { @@ -231,7 +233,7 @@ pub enum Sessions { height: Option<String>, }, /// Load a plugin - #[clap(visible_alias = "r")] + #[clap(visible_alias = "p")] Plugin { /// Plugin URL, can either start with http(s), file: or zellij: #[clap(last(true), required(true))] diff --git a/zellij-utils/src/input/plugins.rs b/zellij-utils/src/input/plugins.rs index eabdd3e84..ec68bd59f 100644 --- a/zellij-utils/src/input/plugins.rs +++ b/zellij-utils/src/input/plugins.rs @@ -25,6 +25,9 @@ impl PluginAliases { pub fn from_data(aliases: BTreeMap<String, RunPlugin>) -> Self { PluginAliases { aliases } } + pub fn list(&self) -> Vec<String> { + self.aliases.keys().cloned().collect() + } } /// Plugin metadata |