Merge pull request #391 from a-kenji/config-loading
Load Config from Assets
This commit is contained in:
commit
f172a01dac
9 changed files with 333 additions and 308 deletions
|
|
@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||||
* Fixes in the default configuration `default.yaml` file. Adds initial tmux-compat keybindings `tmux.yaml` (https://github.com/zellij-org/zellij/pull/362)
|
* Fixes in the default configuration `default.yaml` file. Adds initial tmux-compat keybindings `tmux.yaml` (https://github.com/zellij-org/zellij/pull/362)
|
||||||
* Added the `get_plugin_ids()` query function to the plugin API (https://github.com/zellij-org/zellij/pull/392)
|
* Added the `get_plugin_ids()` query function to the plugin API (https://github.com/zellij-org/zellij/pull/392)
|
||||||
* Implemented simple plugin timers via the `set_timeout()` call (https://github.com/zellij-org/zellij/pull/394)
|
* Implemented simple plugin timers via the `set_timeout()` call (https://github.com/zellij-org/zellij/pull/394)
|
||||||
|
* Added more configuration locations, changed `ZELLIJ_CONFIG` to `ZELLIJ_CONFIG_FILE` (https://github.com/zellij-org/zellij/pull/391)
|
||||||
|
|
||||||
## [0.5.1] - 2021-04-23
|
## [0.5.1] - 2021-04-23
|
||||||
* Change config to flag (https://github.com/zellij-org/zellij/pull/300)
|
* Change config to flag (https://github.com/zellij-org/zellij/pull/300)
|
||||||
|
|
|
||||||
215
assets/config/default.yaml
Normal file
215
assets/config/default.yaml
Normal file
|
|
@ -0,0 +1,215 @@
|
||||||
|
---
|
||||||
|
keybinds:
|
||||||
|
unbind: true
|
||||||
|
normal:
|
||||||
|
- action: [SwitchToMode: Locked,]
|
||||||
|
key: [Ctrl: 'g',]
|
||||||
|
- action: [SwitchToMode: Pane,]
|
||||||
|
key: [Ctrl: 'p',]
|
||||||
|
- action: [SwitchToMode: Resize,]
|
||||||
|
key: [Ctrl: 'r',]
|
||||||
|
- action: [SwitchToMode: Tab,]
|
||||||
|
key: [Ctrl: 't',]
|
||||||
|
- action: [SwitchToMode: Scroll,]
|
||||||
|
key: [Ctrl: 's',]
|
||||||
|
- action: [Quit,]
|
||||||
|
key: [Ctrl: 'q',]
|
||||||
|
- action: [NewPane: ]
|
||||||
|
key: [ Alt: 'n',]
|
||||||
|
- action: [MoveFocus: Left,]
|
||||||
|
key: [ Alt: 'h',]
|
||||||
|
- action: [MoveFocus: Right,]
|
||||||
|
key: [ Alt: 'l',]
|
||||||
|
- action: [MoveFocus: Down,]
|
||||||
|
key: [ Alt: 'j',]
|
||||||
|
- action: [MoveFocus: Up,]
|
||||||
|
key: [ Alt: 'k',]
|
||||||
|
- action: [FocusPreviousPane,]
|
||||||
|
key: [ Alt: '[',]
|
||||||
|
- action: [FocusNextPane,]
|
||||||
|
key: [ Alt: ']',]
|
||||||
|
locked:
|
||||||
|
- action: [SwitchToMode: Normal,]
|
||||||
|
key: [Ctrl: 'g',]
|
||||||
|
resize:
|
||||||
|
- action: [SwitchToMode: Locked,]
|
||||||
|
key: [Ctrl: 'g']
|
||||||
|
- action: [SwitchToMode: Pane,]
|
||||||
|
key: [Ctrl: 'p',]
|
||||||
|
- action: [SwitchToMode: Tab,]
|
||||||
|
key: [Ctrl: 't',]
|
||||||
|
- action: [SwitchToMode: Normal,]
|
||||||
|
key: [Ctrl: 'r', Char: "\n", Char: ' ',]
|
||||||
|
- action: [SwitchToMode: Scroll,]
|
||||||
|
key: [Ctrl: 's']
|
||||||
|
- action: [Quit]
|
||||||
|
key: [Ctrl: 'q']
|
||||||
|
- action: [Resize: Left,]
|
||||||
|
key: [Char: 'h', Left,]
|
||||||
|
- action: [Resize: Down,]
|
||||||
|
key: [Char: 'j', Down,]
|
||||||
|
- action: [Resize: Up,]
|
||||||
|
key: [Char: 'k', Up, ]
|
||||||
|
- action: [Resize: Right,]
|
||||||
|
key: [Char: 'l', Right,]
|
||||||
|
- action: [NewPane: ,]
|
||||||
|
key: [ Alt: 'n',]
|
||||||
|
- action: [MoveFocus: Left,]
|
||||||
|
key: [ Alt: 'h', Left,]
|
||||||
|
- action: [MoveFocus: Right,]
|
||||||
|
key: [ Alt: 'l', Right,]
|
||||||
|
- action: [MoveFocus: Down,]
|
||||||
|
key: [ Alt: 'j', Down,]
|
||||||
|
- action: [MoveFocus: Up,]
|
||||||
|
key: [ Alt: 'k', Up,]
|
||||||
|
- action: [FocusPreviousPane,]
|
||||||
|
key: [ Alt: '[',]
|
||||||
|
- action: [FocusNextPane,]
|
||||||
|
key: [ Alt: ']',]
|
||||||
|
pane:
|
||||||
|
- action: [SwitchToMode: Locked,]
|
||||||
|
key: [Ctrl: 'g']
|
||||||
|
- action: [SwitchToMode: Resize,]
|
||||||
|
key: [Ctrl: 'r',]
|
||||||
|
- action: [SwitchToMode: Tab,]
|
||||||
|
key: [Ctrl: 't',]
|
||||||
|
- action: [SwitchToMode: Normal,]
|
||||||
|
key: [Ctrl: 'p', Char: "\n", Char: ' ',]
|
||||||
|
- action: [SwitchToMode: Scroll,]
|
||||||
|
key: [Ctrl: 's']
|
||||||
|
- action: [Quit,]
|
||||||
|
key: [Ctrl: 'q',]
|
||||||
|
- action: [MoveFocus: Left,]
|
||||||
|
key: [ Char: 'h', Left,]
|
||||||
|
- action: [MoveFocus: Right,]
|
||||||
|
key: [ Char: 'l', Right,]
|
||||||
|
- action: [MoveFocus: Down,]
|
||||||
|
key: [ Char: 'j', Down,]
|
||||||
|
- action: [MoveFocus: Up,]
|
||||||
|
key: [ Char: 'k', Up,]
|
||||||
|
- action: [SwitchFocus,]
|
||||||
|
key: [Char: 'p']
|
||||||
|
- action: [NewPane: ,]
|
||||||
|
key: [Char: 'n', Alt: 'n',]
|
||||||
|
- action: [NewPane: Down,]
|
||||||
|
key: [Char: 'd',]
|
||||||
|
- action: [NewPane: Right,]
|
||||||
|
key: [Char: 'r',]
|
||||||
|
- action: [CloseFocus,]
|
||||||
|
key: [Char: 'x',]
|
||||||
|
- action: [ToggleFocusFullscreen,]
|
||||||
|
key: [Char: 'f',]
|
||||||
|
- action: [FocusPreviousPane,]
|
||||||
|
key: [ Alt: '[',]
|
||||||
|
- action: [FocusNextPane,]
|
||||||
|
key: [ Alt: ']',]
|
||||||
|
tab:
|
||||||
|
- action: [SwitchToMode: Locked,]
|
||||||
|
key: [Ctrl: 'g']
|
||||||
|
- action: [SwitchToMode: Pane,]
|
||||||
|
key: [Ctrl: 'p',]
|
||||||
|
- action: [SwitchToMode: Normal,]
|
||||||
|
key: [Ctrl: 'r', Ctrl: 't', Char: "\n", Char: ' ',]
|
||||||
|
- action: [SwitchToMode: Scroll,]
|
||||||
|
key: [Ctrl: 's']
|
||||||
|
- action: [SwitchToMode: RenameTab, TabNameInput: [0],]
|
||||||
|
key: [Char: 'r']
|
||||||
|
- action: [Quit,]
|
||||||
|
key: [Ctrl: 'q',]
|
||||||
|
- action: [FocusPreviousPane,]
|
||||||
|
key: [ Alt: '[',]
|
||||||
|
- action: [FocusNextPane,]
|
||||||
|
key: [ Alt: ']',]
|
||||||
|
- action: [GoToPreviousTab,]
|
||||||
|
key: [ Char: 'h',]
|
||||||
|
- action: [GoToNextTab,]
|
||||||
|
key: [ Char: 'l',]
|
||||||
|
- action: [GoToNextTab,]
|
||||||
|
key: [ Char: 'j',]
|
||||||
|
- action: [GoToPreviousTab,]
|
||||||
|
key: [ Char: 'k',]
|
||||||
|
- action: [NewTab,]
|
||||||
|
key: [ Char: 'n',]
|
||||||
|
- action: [CloseTab,]
|
||||||
|
key: [ Char: 'x',]
|
||||||
|
- action: [MoveFocus: Left,]
|
||||||
|
key: [ Alt: 'h',]
|
||||||
|
- action: [MoveFocus: Right,]
|
||||||
|
key: [ Alt: 'l',]
|
||||||
|
- action: [MoveFocus: Down,]
|
||||||
|
key: [ Alt: 'j',]
|
||||||
|
- action: [MoveFocus: Up,]
|
||||||
|
key: [ Alt: 'k',]
|
||||||
|
- action: [GoToTab: 1,]
|
||||||
|
key: [ Char: '1',]
|
||||||
|
- action: [GoToTab: 2,]
|
||||||
|
key: [ Char: '2',]
|
||||||
|
- action: [GoToTab: 3,]
|
||||||
|
key: [ Char: '3',]
|
||||||
|
- action: [GoToTab: 4,]
|
||||||
|
key: [ Char: '4',]
|
||||||
|
- action: [GoToTab: 5,]
|
||||||
|
key: [ Char: '5',]
|
||||||
|
- action: [GoToTab: 6,]
|
||||||
|
key: [ Char: '6',]
|
||||||
|
- action: [GoToTab: 7,]
|
||||||
|
key: [ Char: '7',]
|
||||||
|
- action: [GoToTab: 8,]
|
||||||
|
key: [ Char: '8',]
|
||||||
|
- action: [GoToTab: 9,]
|
||||||
|
key: [ Char: '9',]
|
||||||
|
scroll:
|
||||||
|
- action: [SwitchToMode: Normal,]
|
||||||
|
key: [Ctrl: 'r', Ctrl: 's', Char: ' ',
|
||||||
|
Char: "\n",]
|
||||||
|
- action: [SwitchToMode: Tab,]
|
||||||
|
key: [Ctrl: 't',]
|
||||||
|
- action: [SwitchToMode: Locked,]
|
||||||
|
key: [Ctrl: 'g',]
|
||||||
|
- action: [SwitchToMode: Pane,]
|
||||||
|
key: [Ctrl: 'p',]
|
||||||
|
- action: [Quit,]
|
||||||
|
key: [Ctrl: 'q',]
|
||||||
|
- action: [ScrollDown,]
|
||||||
|
key: [Char: 'j', Down,]
|
||||||
|
- action: [ScrollUp,]
|
||||||
|
key: [Char: 'k', Up,]
|
||||||
|
- action: [PageScrollDown,]
|
||||||
|
key: [Ctrl: 'f', PageDown,]
|
||||||
|
- action: [PageScrollUp,]
|
||||||
|
key: [Ctrl: 'b', PageUp,]
|
||||||
|
- action: [NewPane: ,]
|
||||||
|
key: [ Alt: 'n',]
|
||||||
|
- action: [MoveFocus: Left,]
|
||||||
|
key: [ Alt: 'h',]
|
||||||
|
- action: [MoveFocus: Right,]
|
||||||
|
key: [ Alt: 'l',]
|
||||||
|
- action: [MoveFocus: Down,]
|
||||||
|
key: [ Alt: 'j',]
|
||||||
|
- action: [MoveFocus: Up,]
|
||||||
|
key: [ Alt: 'k',]
|
||||||
|
- action: [FocusPreviousPane,]
|
||||||
|
key: [ Alt: '[',]
|
||||||
|
- action: [FocusNextPane,]
|
||||||
|
key: [ Alt: ']',]
|
||||||
|
renametab:
|
||||||
|
- action: [SwitchToMode: Normal,]
|
||||||
|
key: [Ctrl: 'r', Ctrl: 's', Char: ' ',]
|
||||||
|
- action: [SwitchToMode: Tab,]
|
||||||
|
key: [Char: "\n",]
|
||||||
|
- action: [TabNameInput: [27] , SwitchToMode: Tab,]
|
||||||
|
key: [Esc,]
|
||||||
|
- action: [NewPane: ,]
|
||||||
|
key: [ Alt: 'n',]
|
||||||
|
- action: [MoveFocus: Left,]
|
||||||
|
key: [ Alt: 'h',]
|
||||||
|
- action: [MoveFocus: Right,]
|
||||||
|
key: [ Alt: 'l',]
|
||||||
|
- action: [MoveFocus: Down,]
|
||||||
|
key: [ Alt: 'j',]
|
||||||
|
- action: [MoveFocus: Up,]
|
||||||
|
key: [ Alt: 'k',]
|
||||||
|
- action: [FocusPreviousPane,]
|
||||||
|
key: [ Alt: '[',]
|
||||||
|
- action: [FocusNextPane,]
|
||||||
|
key: [ Alt: ']',]
|
||||||
20
src/cli.rs
20
src/cli.rs
|
|
@ -1,9 +1,7 @@
|
||||||
|
use super::common::utils::consts::{ZELLIJ_CONFIG_DIR_ENV, ZELLIJ_CONFIG_FILE_ENV};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
// TODO add to consts.rs
|
|
||||||
const ZELLIJ_CONFIG_ENV: &str = "ZELLIJ_CONFIG";
|
|
||||||
|
|
||||||
#[derive(StructOpt, Default, Debug)]
|
#[derive(StructOpt, Default, Debug)]
|
||||||
#[structopt(name = "zellij")]
|
#[structopt(name = "zellij")]
|
||||||
pub struct CliArgs {
|
pub struct CliArgs {
|
||||||
|
|
@ -32,9 +30,13 @@ pub struct CliArgs {
|
||||||
pub layout: Option<PathBuf>,
|
pub layout: Option<PathBuf>,
|
||||||
|
|
||||||
/// Change where zellij looks for the configuration
|
/// Change where zellij looks for the configuration
|
||||||
#[structopt(short, long, env=ZELLIJ_CONFIG_ENV)]
|
#[structopt(short, long, env=ZELLIJ_CONFIG_FILE_ENV)]
|
||||||
pub config: Option<PathBuf>,
|
pub config: Option<PathBuf>,
|
||||||
|
|
||||||
|
/// Change where zellij looks for the configuration
|
||||||
|
#[structopt(long, env=ZELLIJ_CONFIG_DIR_ENV)]
|
||||||
|
pub config_dir: Option<PathBuf>,
|
||||||
|
|
||||||
#[structopt(subcommand)]
|
#[structopt(subcommand)]
|
||||||
pub option: Option<ConfigCli>,
|
pub option: Option<ConfigCli>,
|
||||||
|
|
||||||
|
|
@ -47,11 +49,19 @@ pub enum ConfigCli {
|
||||||
/// Change the behaviour of zellij
|
/// Change the behaviour of zellij
|
||||||
#[structopt(name = "option")]
|
#[structopt(name = "option")]
|
||||||
Config {
|
Config {
|
||||||
#[structopt(long)]
|
|
||||||
/// Disables loading of configuration file at default location
|
/// Disables loading of configuration file at default location
|
||||||
|
#[structopt(long)]
|
||||||
clean: bool,
|
clean: bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
#[structopt(name = "generate-completion")]
|
#[structopt(name = "generate-completion")]
|
||||||
GenerateCompletion { shell: String },
|
GenerateCompletion { shell: String },
|
||||||
|
|
||||||
|
#[structopt(name = "setup")]
|
||||||
|
Setup {
|
||||||
|
/// Disables loading of configuration file at default location
|
||||||
|
/// Dump the default configuration file to stdout
|
||||||
|
#[structopt(long)]
|
||||||
|
dump_config: bool,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use super::keybinds::{Keybinds, KeybindsFromYaml};
|
use super::keybinds::{Keybinds, KeybindsFromYaml};
|
||||||
use crate::cli::ConfigCli;
|
use crate::cli::ConfigCli;
|
||||||
|
use crate::common::install;
|
||||||
|
|
||||||
use directories_next::ProjectDirs;
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
type ConfigResult = Result<Config, ConfigError>;
|
type ConfigResult = Result<Config, ConfigError>;
|
||||||
|
|
@ -33,6 +33,8 @@ pub enum ConfigError {
|
||||||
Io(io::Error),
|
Io(io::Error),
|
||||||
// Io error with path context
|
// Io error with path context
|
||||||
IoPath(io::Error, PathBuf),
|
IoPath(io::Error, PathBuf),
|
||||||
|
// Internal Deserialisation Error
|
||||||
|
FromUtf8(std::string::FromUtf8Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
|
|
@ -63,18 +65,11 @@ impl Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deserializes the config from a default platform specific path,
|
/// Gets default configuration from assets
|
||||||
/// merges the default configuration - options take precedence.
|
// TODO Deserialize the Configuration from bytes &[u8],
|
||||||
fn from_default_path() -> ConfigResult {
|
// once serde-yaml supports zero-copy
|
||||||
let project_dirs = ProjectDirs::from("org", "Zellij Contributors", "Zellij").unwrap();
|
pub fn from_default_assets() -> ConfigResult {
|
||||||
let mut config_path: PathBuf = project_dirs.config_dir().to_owned();
|
Self::from_yaml(String::from_utf8(install::DEFAULT_CONFIG.to_vec())?.as_str())
|
||||||
config_path.push("config.yaml");
|
|
||||||
|
|
||||||
match Config::new(&config_path) {
|
|
||||||
Ok(config) => Ok(config),
|
|
||||||
Err(ConfigError::IoPath(_, _)) => Ok(Config::default()),
|
|
||||||
Err(e) => Err(e),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Entry point of the configuration
|
/// Entry point of the configuration
|
||||||
|
|
@ -82,20 +77,37 @@ impl Config {
|
||||||
pub fn from_cli_config(
|
pub fn from_cli_config(
|
||||||
location: Option<PathBuf>,
|
location: Option<PathBuf>,
|
||||||
cli_config: Option<ConfigCli>,
|
cli_config: Option<ConfigCli>,
|
||||||
|
config_dir: Option<PathBuf>,
|
||||||
) -> ConfigResult {
|
) -> ConfigResult {
|
||||||
if let Some(path) = location {
|
if let Some(path) = location {
|
||||||
return Config::new(&path);
|
return Config::new(&path);
|
||||||
}
|
}
|
||||||
|
|
||||||
match cli_config {
|
if let Some(ConfigCli::Config { clean, .. }) = cli_config {
|
||||||
Some(ConfigCli::Config { clean, .. }) if clean => Ok(Config::default()),
|
if clean {
|
||||||
Some(_) | None => Ok(Config::from_default_path()?),
|
return Config::from_default_assets();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(config) = config_dir {
|
||||||
|
let path = config.join("config.yaml");
|
||||||
|
if path.exists() {
|
||||||
|
Config::new(&path)
|
||||||
|
} else {
|
||||||
|
Config::from_default_assets()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Config::from_default_assets()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// In order not to mess up tests from changing configurations
|
/// In order not to mess up tests from changing configurations
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub fn from_cli_config(_: Option<PathBuf>, _: Option<ConfigCli>) -> ConfigResult {
|
pub fn from_cli_config(
|
||||||
|
_: Option<PathBuf>,
|
||||||
|
_: Option<ConfigCli>,
|
||||||
|
_: Option<PathBuf>,
|
||||||
|
) -> ConfigResult {
|
||||||
Ok(Config::default())
|
Ok(Config::default())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -108,6 +120,7 @@ impl Display for ConfigError {
|
||||||
write!(formatter, "IoError: {}, File: {}", err, path.display(),)
|
write!(formatter, "IoError: {}, File: {}", err, path.display(),)
|
||||||
}
|
}
|
||||||
ConfigError::Serde(ref err) => write!(formatter, "Deserialisation error: {}", err),
|
ConfigError::Serde(ref err) => write!(formatter, "Deserialisation error: {}", err),
|
||||||
|
ConfigError::FromUtf8(ref err) => write!(formatter, "FromUtf8Error: {}", err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -118,6 +131,7 @@ impl std::error::Error for ConfigError {
|
||||||
ConfigError::Io(ref err) => Some(err),
|
ConfigError::Io(ref err) => Some(err),
|
||||||
ConfigError::IoPath(ref err, _) => Some(err),
|
ConfigError::IoPath(ref err, _) => Some(err),
|
||||||
ConfigError::Serde(ref err) => Some(err),
|
ConfigError::Serde(ref err) => Some(err),
|
||||||
|
ConfigError::FromUtf8(ref err) => Some(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -134,6 +148,12 @@ impl From<serde_yaml::Error> for ConfigError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<std::string::FromUtf8Error> for ConfigError {
|
||||||
|
fn from(err: std::string::FromUtf8Error) -> ConfigError {
|
||||||
|
ConfigError::FromUtf8(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The unit test location.
|
// The unit test location.
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod config_test {
|
mod config_test {
|
||||||
|
|
@ -142,14 +162,14 @@ mod config_test {
|
||||||
#[test]
|
#[test]
|
||||||
fn clean_option_equals_default_config() {
|
fn clean_option_equals_default_config() {
|
||||||
let cli_config = ConfigCli::Config { clean: true };
|
let cli_config = ConfigCli::Config { clean: true };
|
||||||
let config = Config::from_cli_config(None, Some(cli_config)).unwrap();
|
let config = Config::from_cli_config(None, Some(cli_config), None).unwrap();
|
||||||
let default = Config::default();
|
let default = Config::default();
|
||||||
assert_eq!(config, default);
|
assert_eq!(config, default);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_config_option_file_equals_default_config() {
|
fn no_config_option_file_equals_default_config() {
|
||||||
let config = Config::from_cli_config(None, None).unwrap();
|
let config = Config::from_cli_config(None, None, None).unwrap();
|
||||||
let default = Config::default();
|
let default = Config::default();
|
||||||
assert_eq!(config, default);
|
assert_eq!(config, default);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
//! Mapping of inputs to sequences of actions.
|
//! Mapping of inputs to sequences of actions.
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use super::actions::{Action, Direction};
|
use super::actions::Action;
|
||||||
|
use super::config;
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
@ -57,14 +58,9 @@ enum Unbind {
|
||||||
|
|
||||||
impl Default for Keybinds {
|
impl Default for Keybinds {
|
||||||
fn default() -> Keybinds {
|
fn default() -> Keybinds {
|
||||||
let mut defaults = Keybinds::new();
|
config::Config::from_default_assets()
|
||||||
|
.expect("Keybinds from default assets Error")
|
||||||
for mode in InputMode::iter() {
|
.keybinds
|
||||||
defaults
|
|
||||||
.0
|
|
||||||
.insert(mode, Keybinds::get_defaults_for_mode(&mode));
|
|
||||||
}
|
|
||||||
defaults
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -109,278 +105,6 @@ impl Keybinds {
|
||||||
keybinds
|
keybinds
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the default keybinds for a given [`InputMode`].
|
|
||||||
fn get_defaults_for_mode(mode: &InputMode) -> ModeKeybinds {
|
|
||||||
let mut defaults = HashMap::new();
|
|
||||||
|
|
||||||
match *mode {
|
|
||||||
InputMode::Normal => {
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('g'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Locked)],
|
|
||||||
);
|
|
||||||
defaults.insert(Key::Ctrl('p'), vec![Action::SwitchToMode(InputMode::Pane)]);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('r'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Resize)],
|
|
||||||
);
|
|
||||||
defaults.insert(Key::Ctrl('t'), vec![Action::SwitchToMode(InputMode::Tab)]);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('s'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Scroll)],
|
|
||||||
);
|
|
||||||
defaults.insert(Key::Ctrl('q'), vec![Action::Quit]);
|
|
||||||
|
|
||||||
defaults.insert(Key::Alt('n'), vec![Action::NewPane(None)]);
|
|
||||||
defaults.insert(Key::Alt('h'), vec![Action::MoveFocus(Direction::Left)]);
|
|
||||||
defaults.insert(Key::Alt('j'), vec![Action::MoveFocus(Direction::Down)]);
|
|
||||||
defaults.insert(Key::Alt('k'), vec![Action::MoveFocus(Direction::Up)]);
|
|
||||||
defaults.insert(Key::Alt('l'), vec![Action::MoveFocus(Direction::Right)]);
|
|
||||||
defaults.insert(Key::Alt('['), vec![Action::FocusPreviousPane]);
|
|
||||||
defaults.insert(Key::Alt(']'), vec![Action::FocusNextPane]);
|
|
||||||
}
|
|
||||||
InputMode::Locked => {
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('g'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
InputMode::Resize => {
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('g'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Locked)],
|
|
||||||
);
|
|
||||||
defaults.insert(Key::Ctrl('p'), vec![Action::SwitchToMode(InputMode::Pane)]);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('r'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
|
||||||
);
|
|
||||||
defaults.insert(Key::Ctrl('t'), vec![Action::SwitchToMode(InputMode::Tab)]);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('s'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Scroll)],
|
|
||||||
);
|
|
||||||
defaults.insert(Key::Ctrl('q'), vec![Action::Quit]);
|
|
||||||
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Normal)]);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Char('\n'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
|
||||||
);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Char(' '),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
|
||||||
);
|
|
||||||
|
|
||||||
defaults.insert(Key::Char('h'), vec![Action::Resize(Direction::Left)]);
|
|
||||||
defaults.insert(Key::Char('j'), vec![Action::Resize(Direction::Down)]);
|
|
||||||
defaults.insert(Key::Char('k'), vec![Action::Resize(Direction::Up)]);
|
|
||||||
defaults.insert(Key::Char('l'), vec![Action::Resize(Direction::Right)]);
|
|
||||||
|
|
||||||
defaults.insert(Key::Left, vec![Action::Resize(Direction::Left)]);
|
|
||||||
defaults.insert(Key::Down, vec![Action::Resize(Direction::Down)]);
|
|
||||||
defaults.insert(Key::Up, vec![Action::Resize(Direction::Up)]);
|
|
||||||
defaults.insert(Key::Right, vec![Action::Resize(Direction::Right)]);
|
|
||||||
|
|
||||||
defaults.insert(Key::Alt('n'), vec![Action::NewPane(None)]);
|
|
||||||
defaults.insert(Key::Alt('h'), vec![Action::MoveFocus(Direction::Left)]);
|
|
||||||
defaults.insert(Key::Alt('j'), vec![Action::MoveFocus(Direction::Down)]);
|
|
||||||
defaults.insert(Key::Alt('k'), vec![Action::MoveFocus(Direction::Up)]);
|
|
||||||
defaults.insert(Key::Alt('l'), vec![Action::MoveFocus(Direction::Right)]);
|
|
||||||
defaults.insert(Key::Alt('['), vec![Action::FocusPreviousPane]);
|
|
||||||
defaults.insert(Key::Alt(']'), vec![Action::FocusNextPane]);
|
|
||||||
}
|
|
||||||
InputMode::Pane => {
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('g'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Locked)],
|
|
||||||
);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('p'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
|
||||||
);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('r'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Resize)],
|
|
||||||
);
|
|
||||||
defaults.insert(Key::Ctrl('t'), vec![Action::SwitchToMode(InputMode::Tab)]);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('s'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Scroll)],
|
|
||||||
);
|
|
||||||
defaults.insert(Key::Ctrl('q'), vec![Action::Quit]);
|
|
||||||
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Normal)]);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Char('\n'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
|
||||||
);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Char(' '),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
|
||||||
);
|
|
||||||
|
|
||||||
defaults.insert(Key::Char('h'), vec![Action::MoveFocus(Direction::Left)]);
|
|
||||||
defaults.insert(Key::Char('j'), vec![Action::MoveFocus(Direction::Down)]);
|
|
||||||
defaults.insert(Key::Char('k'), vec![Action::MoveFocus(Direction::Up)]);
|
|
||||||
defaults.insert(Key::Char('l'), vec![Action::MoveFocus(Direction::Right)]);
|
|
||||||
|
|
||||||
defaults.insert(Key::Left, vec![Action::MoveFocus(Direction::Left)]);
|
|
||||||
defaults.insert(Key::Down, vec![Action::MoveFocus(Direction::Down)]);
|
|
||||||
defaults.insert(Key::Up, vec![Action::MoveFocus(Direction::Up)]);
|
|
||||||
defaults.insert(Key::Right, vec![Action::MoveFocus(Direction::Right)]);
|
|
||||||
|
|
||||||
defaults.insert(Key::Char('p'), vec![Action::SwitchFocus]);
|
|
||||||
defaults.insert(Key::Char('n'), vec![Action::NewPane(None)]);
|
|
||||||
defaults.insert(Key::Char('d'), vec![Action::NewPane(Some(Direction::Down))]);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Char('r'),
|
|
||||||
vec![Action::NewPane(Some(Direction::Right))],
|
|
||||||
);
|
|
||||||
defaults.insert(Key::Char('x'), vec![Action::CloseFocus]);
|
|
||||||
defaults.insert(Key::Char('f'), vec![Action::ToggleFocusFullscreen]);
|
|
||||||
|
|
||||||
defaults.insert(Key::Alt('n'), vec![Action::NewPane(None)]);
|
|
||||||
defaults.insert(Key::Alt('h'), vec![Action::MoveFocus(Direction::Left)]);
|
|
||||||
defaults.insert(Key::Alt('j'), vec![Action::MoveFocus(Direction::Down)]);
|
|
||||||
defaults.insert(Key::Alt('k'), vec![Action::MoveFocus(Direction::Up)]);
|
|
||||||
defaults.insert(Key::Alt('l'), vec![Action::MoveFocus(Direction::Right)]);
|
|
||||||
defaults.insert(Key::Alt('['), vec![Action::FocusPreviousPane]);
|
|
||||||
defaults.insert(Key::Alt(']'), vec![Action::FocusNextPane]);
|
|
||||||
}
|
|
||||||
InputMode::Tab => {
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('g'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Locked)],
|
|
||||||
);
|
|
||||||
defaults.insert(Key::Ctrl('p'), vec![Action::SwitchToMode(InputMode::Pane)]);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('r'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Resize)],
|
|
||||||
);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('t'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
|
||||||
);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('s'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Scroll)],
|
|
||||||
);
|
|
||||||
defaults.insert(Key::Ctrl('q'), vec![Action::Quit]);
|
|
||||||
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Normal)]);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Char('\n'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
|
||||||
);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Char(' '),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
|
||||||
);
|
|
||||||
|
|
||||||
defaults.insert(Key::Char('h'), vec![Action::GoToPreviousTab]);
|
|
||||||
defaults.insert(Key::Char('j'), vec![Action::GoToNextTab]);
|
|
||||||
defaults.insert(Key::Char('k'), vec![Action::GoToPreviousTab]);
|
|
||||||
defaults.insert(Key::Char('l'), vec![Action::GoToNextTab]);
|
|
||||||
|
|
||||||
defaults.insert(Key::Left, vec![Action::GoToPreviousTab]);
|
|
||||||
defaults.insert(Key::Down, vec![Action::GoToNextTab]);
|
|
||||||
defaults.insert(Key::Up, vec![Action::GoToPreviousTab]);
|
|
||||||
defaults.insert(Key::Right, vec![Action::GoToNextTab]);
|
|
||||||
|
|
||||||
defaults.insert(Key::Char('n'), vec![Action::NewTab]);
|
|
||||||
defaults.insert(Key::Char('x'), vec![Action::CloseTab]);
|
|
||||||
|
|
||||||
defaults.insert(
|
|
||||||
Key::Char('r'),
|
|
||||||
vec![
|
|
||||||
Action::SwitchToMode(InputMode::RenameTab),
|
|
||||||
Action::TabNameInput(vec![0]),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('g'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
|
||||||
);
|
|
||||||
for i in '1'..='9' {
|
|
||||||
defaults.insert(Key::Char(i), vec![Action::GoToTab(i.to_digit(10).unwrap())]);
|
|
||||||
}
|
|
||||||
defaults.insert(Key::Alt('n'), vec![Action::NewPane(None)]);
|
|
||||||
defaults.insert(Key::Alt('h'), vec![Action::MoveFocus(Direction::Left)]);
|
|
||||||
defaults.insert(Key::Alt('j'), vec![Action::MoveFocus(Direction::Down)]);
|
|
||||||
defaults.insert(Key::Alt('k'), vec![Action::MoveFocus(Direction::Up)]);
|
|
||||||
defaults.insert(Key::Alt('l'), vec![Action::MoveFocus(Direction::Right)]);
|
|
||||||
defaults.insert(Key::Alt('['), vec![Action::FocusPreviousPane]);
|
|
||||||
defaults.insert(Key::Alt(']'), vec![Action::FocusNextPane]);
|
|
||||||
}
|
|
||||||
InputMode::Scroll => {
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('g'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Locked)],
|
|
||||||
);
|
|
||||||
defaults.insert(Key::Ctrl('p'), vec![Action::SwitchToMode(InputMode::Pane)]);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('r'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Resize)],
|
|
||||||
);
|
|
||||||
defaults.insert(Key::Ctrl('t'), vec![Action::SwitchToMode(InputMode::Tab)]);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('s'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
|
||||||
);
|
|
||||||
defaults.insert(Key::Ctrl('q'), vec![Action::Quit]);
|
|
||||||
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Normal)]);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Char('\n'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
|
||||||
);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Char(' '),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
|
||||||
);
|
|
||||||
|
|
||||||
defaults.insert(Key::Char('j'), vec![Action::ScrollDown]);
|
|
||||||
defaults.insert(Key::Char('k'), vec![Action::ScrollUp]);
|
|
||||||
|
|
||||||
defaults.insert(Key::Ctrl('f'), vec![Action::PageScrollDown]);
|
|
||||||
defaults.insert(Key::Ctrl('b'), vec![Action::PageScrollUp]);
|
|
||||||
defaults.insert(Key::PageDown, vec![Action::PageScrollDown]);
|
|
||||||
defaults.insert(Key::PageUp, vec![Action::PageScrollUp]);
|
|
||||||
|
|
||||||
defaults.insert(Key::Down, vec![Action::ScrollDown]);
|
|
||||||
defaults.insert(Key::Up, vec![Action::ScrollUp]);
|
|
||||||
|
|
||||||
defaults.insert(Key::Alt('n'), vec![Action::NewPane(None)]);
|
|
||||||
defaults.insert(Key::Alt('h'), vec![Action::MoveFocus(Direction::Left)]);
|
|
||||||
defaults.insert(Key::Alt('j'), vec![Action::MoveFocus(Direction::Down)]);
|
|
||||||
defaults.insert(Key::Alt('k'), vec![Action::MoveFocus(Direction::Up)]);
|
|
||||||
defaults.insert(Key::Alt('l'), vec![Action::MoveFocus(Direction::Right)]);
|
|
||||||
defaults.insert(Key::Alt('['), vec![Action::FocusPreviousPane]);
|
|
||||||
defaults.insert(Key::Alt(']'), vec![Action::FocusNextPane]);
|
|
||||||
}
|
|
||||||
InputMode::RenameTab => {
|
|
||||||
defaults.insert(Key::Char('\n'), vec![Action::SwitchToMode(InputMode::Tab)]);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Ctrl('g'),
|
|
||||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
|
||||||
);
|
|
||||||
defaults.insert(
|
|
||||||
Key::Esc,
|
|
||||||
vec![
|
|
||||||
Action::TabNameInput(vec![0x1b]),
|
|
||||||
Action::SwitchToMode(InputMode::Tab),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
defaults.insert(Key::Alt('n'), vec![Action::NewPane(None)]);
|
|
||||||
defaults.insert(Key::Alt('h'), vec![Action::MoveFocus(Direction::Left)]);
|
|
||||||
defaults.insert(Key::Alt('j'), vec![Action::MoveFocus(Direction::Down)]);
|
|
||||||
defaults.insert(Key::Alt('k'), vec![Action::MoveFocus(Direction::Up)]);
|
|
||||||
defaults.insert(Key::Alt('l'), vec![Action::MoveFocus(Direction::Right)]);
|
|
||||||
defaults.insert(Key::Alt('['), vec![Action::FocusPreviousPane]);
|
|
||||||
defaults.insert(Key::Alt(']'), vec![Action::FocusNextPane]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ModeKeybinds(defaults)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Converts a [`Key`] terminal event to a sequence of [`Action`]s according to the current
|
/// Converts a [`Key`] terminal event to a sequence of [`Action`]s according to the current
|
||||||
/// [`InputMode`] and [`Keybinds`].
|
/// [`InputMode`] and [`Keybinds`].
|
||||||
pub fn key_to_actions(
|
pub fn key_to_actions(
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
use std::{fs, path::Path};
|
use crate::common::utils::consts::SYSTEM_DEFAULT_CONFIG_DIR;
|
||||||
|
use directories_next::{BaseDirs, ProjectDirs};
|
||||||
|
use std::io::Write;
|
||||||
|
use std::{fs, path::Path, path::PathBuf};
|
||||||
|
|
||||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
|
|
@ -39,3 +42,44 @@ pub fn populate_data_dir(data_dir: &Path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn default_config_dir() -> Option<PathBuf> {
|
||||||
|
vec![
|
||||||
|
Some(xdg_config_dir()),
|
||||||
|
home_config_dir(),
|
||||||
|
Some(Path::new(SYSTEM_DEFAULT_CONFIG_DIR).to_path_buf()),
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.filter(|p| p.is_some())
|
||||||
|
.find(|p| p.clone().unwrap().exists())
|
||||||
|
.flatten()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn xdg_config_dir() -> PathBuf {
|
||||||
|
let project_dirs = ProjectDirs::from("org", "Zellij Contributors", "Zellij").unwrap();
|
||||||
|
project_dirs.config_dir().to_owned()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn home_config_dir() -> Option<PathBuf> {
|
||||||
|
if let Some(user_dirs) = BaseDirs::new() {
|
||||||
|
let config_dir = user_dirs.home_dir().join("/.config/zellij");
|
||||||
|
Some(config_dir)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn dump_asset(asset: &[u8]) -> std::io::Result<()> {
|
||||||
|
std::io::stdout().write_all(&asset)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const DEFAULT_CONFIG: &[u8] = include_bytes!(concat!(
|
||||||
|
env!("CARGO_MANIFEST_DIR"),
|
||||||
|
"/",
|
||||||
|
"assets/config/default.yaml"
|
||||||
|
));
|
||||||
|
|
||||||
|
pub fn dump_default_config() -> std::io::Result<()> {
|
||||||
|
dump_asset(DEFAULT_CONFIG)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,9 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
||||||
|
|
||||||
env::set_var(&"ZELLIJ", "0");
|
env::set_var(&"ZELLIJ", "0");
|
||||||
|
|
||||||
let config = Config::from_cli_config(opts.config, opts.option)
|
let config_dir = opts.config_dir.or_else(install::default_config_dir);
|
||||||
|
|
||||||
|
let config = Config::from_cli_config(opts.config, opts.option, config_dir)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("There was an error in the config file:\n{}", e);
|
eprintln!("There was an error in the config file:\n{}", e);
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
|
|
|
||||||
|
|
@ -4,3 +4,9 @@ pub const ZELLIJ_TMP_DIR: &str = "/tmp/zellij";
|
||||||
pub const ZELLIJ_TMP_LOG_DIR: &str = "/tmp/zellij/zellij-log";
|
pub const ZELLIJ_TMP_LOG_DIR: &str = "/tmp/zellij/zellij-log";
|
||||||
pub const ZELLIJ_TMP_LOG_FILE: &str = "/tmp/zellij/zellij-log/log.txt";
|
pub const ZELLIJ_TMP_LOG_FILE: &str = "/tmp/zellij/zellij-log/log.txt";
|
||||||
pub const ZELLIJ_IPC_PIPE: &str = "/tmp/zellij/ipc";
|
pub const ZELLIJ_IPC_PIPE: &str = "/tmp/zellij/ipc";
|
||||||
|
|
||||||
|
pub const ZELLIJ_CONFIG_FILE_ENV: &str = "ZELLIJ_CONFIG_FILE";
|
||||||
|
pub const ZELLIJ_CONFIG_DIR_ENV: &str = "ZELLIJ_CONFIG_DIR";
|
||||||
|
|
||||||
|
// TODO: ${PREFIX} argument in makefile
|
||||||
|
pub const SYSTEM_DEFAULT_CONFIG_DIR: &str = "/etc/zellij";
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ use crate::utils::{
|
||||||
};
|
};
|
||||||
use client::{boundaries, layout, panes, tab};
|
use client::{boundaries, layout, panes, tab};
|
||||||
use common::{
|
use common::{
|
||||||
command_is_executing, errors, os_input_output, pty_bus, screen, start, utils, wasm_vm,
|
command_is_executing, errors, install, os_input_output, pty_bus, screen, start, utils, wasm_vm,
|
||||||
ApiCommand,
|
ApiCommand,
|
||||||
};
|
};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
@ -59,6 +59,9 @@ pub fn main() {
|
||||||
};
|
};
|
||||||
let mut out = std::io::stdout();
|
let mut out = std::io::stdout();
|
||||||
CliArgs::clap().gen_completions_to("zellij", shell, &mut out);
|
CliArgs::clap().gen_completions_to("zellij", shell, &mut out);
|
||||||
|
} else if let Some(crate::cli::ConfigCli::Setup { .. }) = opts.option {
|
||||||
|
install::dump_default_config().expect("Failed to print to stdout");
|
||||||
|
std::process::exit(1);
|
||||||
} else {
|
} else {
|
||||||
let os_input = get_os_input();
|
let os_input = get_os_input();
|
||||||
atomic_create_dir(ZELLIJ_TMP_DIR).unwrap();
|
atomic_create_dir(ZELLIJ_TMP_DIR).unwrap();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue