aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index ab62c1aa..8c0a005c 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -2042,6 +2042,25 @@ mod cmd {
quit_all_impl(&mut cx.editor, args, event, true)
}
+ fn cquit(
+ cx: &mut compositor::Context,
+ args: &[&str],
+ _event: PromptEvent,
+ ) -> anyhow::Result<()> {
+ let exit_code = args
+ .first()
+ .and_then(|code| code.parse::<i32>().ok())
+ .unwrap_or(1);
+ cx.editor.exit_code = exit_code;
+
+ let views: Vec<_> = cx.editor.tree.views().map(|(view, _)| view.id).collect();
+ for view_id in views {
+ cx.editor.close(view_id, false);
+ }
+
+ Ok(())
+ }
+
fn theme(
cx: &mut compositor::Context,
args: &[&str],
@@ -2412,6 +2431,13 @@ mod cmd {
completer: None,
},
TypableCommand {
+ name: "cquit",
+ aliases: &["cq"],
+ doc: "Quit with exit code (default 1). Accepts an optional integer exit code (:cq 2).",
+ fun: cquit,
+ completer: None,
+ },
+ TypableCommand {
name: "theme",
aliases: &[],
doc: "Change the theme of current view. Requires theme name as argument (:theme <name>)",