aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKunal Mohan <kunalmohan99@gmail.com>2021-05-21 02:22:01 +0530
committerKunal Mohan <kunalmohan99@gmail.com>2021-05-22 22:19:50 +0530
commitac082a1c930a356253f5cb3b685aabe28f87cba6 (patch)
tree120e324b7610a5e59ac9401f6b4ab52c306382d9
parentUse Action enum for Quit and detach instead of separate messages under Client... (diff)
downloadsl0ppij-ac082a1c930a356253f5cb3b685aabe28f87cba6.tar.gz
sl0ppij-ac082a1c930a356253f5cb3b685aabe28f87cba6.tar.xz
sl0ppij-ac082a1c930a356253f5cb3b685aabe28f87cba6.zip
add keybinds for session mode and detach
-rw-r--r--assets/config/default.yaml27
-rw-r--r--default-plugins/status-bar/src/first_line.rs24
-rw-r--r--zellij-tile/src/data.rs3
-rw-r--r--zellij-utils/src/input/mod.rs3
4 files changed, 57 insertions, 0 deletions
diff --git a/assets/config/default.yaml b/assets/config/default.yaml
index 4582e79f..e649f2ae 100644
--- a/assets/config/default.yaml
+++ b/assets/config/default.yaml
@@ -12,6 +12,8 @@ keybinds:
key: [Ctrl: 't',]
- action: [SwitchToMode: Scroll,]
key: [Ctrl: 's',]
+ - action: [SwitchToMode: Session,]
+ key: [Ctrl: 'b',]
- action: [Quit,]
key: [Ctrl: 'q',]
- action: [NewPane: ]
@@ -42,6 +44,8 @@ keybinds:
key: [Ctrl: 'r', Char: "\n", Char: ' ',]
- action: [SwitchToMode: Scroll,]
key: [Ctrl: 's']
+ - action: [SwitchToMode: Session,]
+ key: [Ctrl: 'b',]
- action: [Quit]
key: [Ctrl: 'q']
- action: [Resize: Left,]
@@ -77,6 +81,8 @@ keybinds:
key: [Ctrl: 'p', Char: "\n", Char: ' ',]
- action: [SwitchToMode: Scroll,]
key: [Ctrl: 's']
+ - action: [SwitchToMode: Session,]
+ key: [Ctrl: 'b',]
- action: [Quit,]
key: [Ctrl: 'q',]
- action: [MoveFocus: Left,]
@@ -114,6 +120,8 @@ keybinds:
key: [Ctrl: 't', Char: "\n", Char: ' ',]
- action: [SwitchToMode: Scroll,]
key: [Ctrl: 's']
+ - action: [SwitchToMode: Session,]
+ key: [Ctrl: 'b',]
- action: [SwitchToMode: RenameTab, TabNameInput: [0],]
key: [Char: 'r']
- action: [Quit,]
@@ -168,6 +176,8 @@ keybinds:
key: [Ctrl: 'g',]
- action: [SwitchToMode: Pane,]
key: [Ctrl: 'p',]
+ - action: [SwitchToMode: Session,]
+ key: [Ctrl: 'b',]
- action: [Quit,]
key: [Ctrl: 'q',]
- action: [ScrollDown,]
@@ -213,3 +223,20 @@ keybinds:
key: [ Alt: '[',]
- action: [FocusNextPane,]
key: [ Alt: ']',]
+ session:
+ - action: [SwitchToMode: Locked,]
+ key: [Ctrl: 'g']
+ - action: [SwitchToMode: Resize,]
+ key: [Ctrl: 'r',]
+ - action: [SwitchToMode: Pane,]
+ key: [Ctrl: 'p',]
+ - action: [SwitchToMode: Tab,]
+ key: [Ctrl: 't',]
+ - action: [SwitchToMode: Normal,]
+ key: [Ctrl: 'b', Char: "\n", Char: ' ',]
+ - action: [SwitchToMode: Scroll,]
+ key: [Ctrl: 's']
+ - action: [Quit,]
+ key: [Ctrl: 'q',]
+ - action: [Detach,]
+ key: [Char: 'd',]
diff --git a/default-plugins/status-bar/src/first_line.rs b/default-plugins/status-bar/src/first_line.rs
index 37175e3f..b6a01fd9 100644
--- a/default-plugins/status-bar/src/first_line.rs
+++ b/default-plugins/status-bar/src/first_line.rs
@@ -22,6 +22,7 @@ enum CtrlKeyAction {
Resize,
Scroll,
Quit,
+ Session,
}
enum CtrlKeyMode {
@@ -39,6 +40,7 @@ impl CtrlKeyShortcut {
CtrlKeyAction::Resize => String::from("RESIZE"),
CtrlKeyAction::Scroll => String::from("SCROLL"),
CtrlKeyAction::Quit => String::from("QUIT"),
+ CtrlKeyAction::Session => String::from("SESSION"),
}
}
pub fn shortened_text(&self) -> String {
@@ -49,6 +51,7 @@ impl CtrlKeyShortcut {
CtrlKeyAction::Resize => String::from("esize"),
CtrlKeyAction::Scroll => String::from("croll"),
CtrlKeyAction::Quit => String::from("uit"),
+ CtrlKeyAction::Session => String::from("sess"),
}
}
pub fn letter_shortcut(&self) -> char {
@@ -59,6 +62,7 @@ impl CtrlKeyShortcut {
CtrlKeyAction::Resize => 'r',
CtrlKeyAction::Scroll => 's',
CtrlKeyAction::Quit => 'q',
+ CtrlKeyAction::Session => 'b',
}
}
}
@@ -297,6 +301,7 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize, separator: &str) -> LinePart {
CtrlKeyShortcut::new(CtrlKeyMode::Disabled, CtrlKeyAction::Resize),
CtrlKeyShortcut::new(CtrlKeyMode::Disabled, CtrlKeyAction::Scroll),
CtrlKeyShortcut::new(CtrlKeyMode::Disabled, CtrlKeyAction::Quit),
+ CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Session),
],
colored_elements,
separator,
@@ -310,6 +315,7 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize, separator: &str) -> LinePart {
CtrlKeyShortcut::new(CtrlKeyMode::Selected, CtrlKeyAction::Resize),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Scroll),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit),
+ CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Session),
],
colored_elements,
separator,
@@ -323,6 +329,7 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize, separator: &str) -> LinePart {
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Resize),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Scroll),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit),
+ CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Session),
],
colored_elements,
separator,
@@ -336,6 +343,7 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize, separator: &str) -> LinePart {
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Resize),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Scroll),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit),
+ CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Session),
],
colored_elements,
separator,
@@ -349,6 +357,7 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize, separator: &str) -> LinePart {
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Resize),
CtrlKeyShortcut::new(CtrlKeyMode::Selected, CtrlKeyAction::Scroll),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit),
+ CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Session),
],
colored_elements,
separator,
@@ -362,6 +371,21 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize, separator: &str) -> LinePart {
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Resize),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Scroll),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit),
+ CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Session),
+ ],
+ colored_elements,
+ separator,
+ ),
+ InputMode::Session => key_indicators(
+ max_len,
+ &[
+ CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Lock),
+ CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Pane),
+ CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Tab),
+ CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Resize),
+ CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Scroll),
+ CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit),
+ CtrlKeyShortcut::new(CtrlKeyMode::Selected, CtrlKeyAction::Session),
],
colored_elements,
separator,
diff --git a/zellij-tile/src/data.rs b/zellij-tile/src/data.rs
index c1b9c30e..cb4b2aa0 100644
--- a/zellij-tile/src/data.rs
+++ b/zellij-tile/src/data.rs
@@ -59,6 +59,9 @@ pub enum InputMode {
Scroll,
#[serde(alias = "renametab")]
RenameTab,
+ /// `Session` mode allows detaching sessions
+ #[serde(alias = "session")]
+ Session,
}
impl Default for InputMode {
diff --git a/zellij-utils/src/input/mod.rs b/zellij-utils/src/input/mod.rs
index 2747205b..068e22bc 100644
--- a/zellij-utils/src/input/mod.rs
+++ b/zellij-utils/src/input/mod.rs
@@ -45,6 +45,9 @@ pub fn get_mode_info(
InputMode::RenameTab => {
keybinds.push(("Enter".to_string(), "when done".to_string()));
}
+ InputMode::Session => {
+ keybinds.push(("d".to_string(), "Detach".to_string()));
+ }
}
ModeInfo {
mode,