summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2024-03-20 17:18:05 +0100
committerAram Drevekenin <aram@poor.dev>2024-03-20 17:18:05 +0100
commit5b7d8287f7800b2e817bab8ccdde2faaeb7ae88e (patch)
treeaf6d382a4c44027329384b25a704037bf867ae7f
parenta4f3c62de9d337ed6c173d3cc183a5b6b98ae758 (diff)
chore(integrations): zpipe aliaszpipe-alias
-rw-r--r--src/commands.rs20
-rw-r--r--src/main.rs2
-rw-r--r--zellij-utils/assets/completions/comp.fish6
-rw-r--r--zellij-utils/src/cli.rs4
-rw-r--r--zellij-utils/src/input/plugins.rs3
5 files changed, 34 insertions, 1 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.fish b/zellij-utils/assets/completions/comp.fish
index 973d49006..20591edc9 100644
--- a/zellij-utils/assets/completions/comp.fish
+++ b/zellij-utils/assets/completions/comp.fish
@@ -18,6 +18,11 @@ 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
@@ -25,3 +30,4 @@ function zpipe
command zellij pipe
end
end
+complete -c zpipe -f -a "(__fish_complete_aliases)" -d "Zpipes"
diff --git a/zellij-utils/src/cli.rs b/zellij-utils/src/cli.rs
index d2e93d712..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 {
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