From f5afbe8984c3eb15dba74faf02aa6d2d7cb894cb Mon Sep 17 00:00:00 2001 From: Matthew Nicholson Date: Sun, 25 Aug 2019 00:51:12 -0400 Subject: [PATCH 1/2] write the config after removing a key --- src/commands/config.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commands/config.rs b/src/commands/config.rs index b1400207c..c41c1d374 100644 --- a/src/commands/config.rs +++ b/src/commands/config.rs @@ -111,6 +111,7 @@ pub fn config( if result.contains_key(&key) { result.remove(&key); + config::write_config(&result)?; } else { return Err(ShellError::string(&format!( "{} does not exist in config", From 6ebf6f8a8f6188b44a0a425a4e01405586f2cfe3 Mon Sep 17 00:00:00 2001 From: Matthew Nicholson Date: Sun, 25 Aug 2019 01:12:23 -0400 Subject: [PATCH 2/2] set rustyline's edit_mode based on a config option This adds support for vi mode. --- src/cli.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/cli.rs b/src/cli.rs index 28fef9556..48fc71223 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -17,7 +17,7 @@ use crate::prelude::*; use log::{debug, trace}; use regex::Regex; use rustyline::error::ReadlineError; -use rustyline::{self, ColorMode, Config, Editor}; +use rustyline::{self, ColorMode, Config, Editor, config::Configurer, config::EditMode}; use std::env; use std::error::Error; use std::io::{BufRead, BufReader, Write}; @@ -234,6 +234,17 @@ pub async fn cli() -> Result<(), Box> { context.shell_manager.clone(), ))); + let edit_mode = crate::object::config::config(Span::unknown())? + .get("edit_mode") + .map(|s| match s.as_string().unwrap().as_ref() { + "vi" => EditMode::Vi, + "emacs" => EditMode::Emacs, + _ => EditMode::Emacs, + }) + .unwrap_or(EditMode::Emacs); + + rl.set_edit_mode(edit_mode); + let readline = rl.readline(&format!( "{}{}> ", cwd,