feat: Display Vi mode as PROMPT (#169)

Add Vi-mode indicator for zsh
This commit is contained in:
Shu Kutsuzawa
2019-08-18 04:33:19 +09:00
committed by Kevin Song
parent 9c213b36b0
commit d90c43b8b1
6 changed files with 56 additions and 13 deletions
+5
View File
@@ -12,6 +12,8 @@ use ansi_term::Color;
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
const SUCCESS_CHAR: &str = "";
const FAILURE_CHAR: &str = "";
const VICMD_CHAR: &str = "";
let color_success = Color::Green.bold();
let color_failure = Color::Red.bold();
@@ -23,11 +25,14 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
.config_value_bool("use_symbol_for_status")
.unwrap_or(false);
let exit_success = arguments.value_of("status_code").unwrap_or("0") == "0";
let keymap = arguments.value_of("keymap").unwrap_or("viins");
/* If an error symbol is set in the config, use symbols to indicate
success/failure, in addition to color */
let symbol = if use_symbol && !exit_success {
module.new_segment("error_symbol", FAILURE_CHAR)
} else if keymap == "vicmd" {
module.new_segment("vicmd_symbol", VICMD_CHAR)
} else {
module.new_segment("symbol", SUCCESS_CHAR)
};
-13
View File
@@ -111,17 +111,4 @@ mod tests {
let input = "Python 3.7.2";
assert_eq!(format_python_version(input), "v3.7.2");
}
#[test]
fn test_no_virtual_env() {
env::set_var("VIRTUAL_ENV", "");
assert_eq!(get_python_virtual_env(), None)
}
#[test]
fn test_virtual_env() {
env::set_var("VIRTUAL_ENV", "/foo/bar/my_venv");
assert_eq!(get_python_virtual_env().unwrap(), "my_venv")
}
}