diff --git a/Cargo.lock b/Cargo.lock index e75fa5f..6715d13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -64,7 +64,7 @@ name = "backtrace-sys" version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -84,7 +84,7 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -121,10 +121,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "curl-sys" -version = "0.4.16" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -207,8 +207,8 @@ name = "libgit2-sys" version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", - "curl-sys 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", + "curl-sys 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "libssh2-sys 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", @@ -221,7 +221,7 @@ name = "libssh2-sys" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -234,7 +234,7 @@ name = "libz-sys" version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -273,7 +273,7 @@ name = "openssl-sys" version = "0.9.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -575,12 +575,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" -"checksum cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)" = "d01c69d08ff207f231f07196e30f84c70f1c815b04f980f8b7b01ff01f05eb92" +"checksum cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)" = "c9ce8bb087aacff865633f0bd5aeaed910fe2fe55b55f4739527f2e023a2e53d" "checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" -"checksum curl-sys 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)" = "ca79238a79fb294be6173b4057c95b22a718c94c4e38475d5faa82b8383f3502" +"checksum curl-sys 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)" = "7b8d8e51964f58c8053337fcef48e1c4608c7ee70c6f2e457674a97dda5a5828" "checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" diff --git a/src/precmd.rs b/src/precmd.rs index e41b1c7..2174601 100644 --- a/src/precmd.rs +++ b/src/precmd.rs @@ -1,5 +1,5 @@ -use ansi_term::Colour::{Blue, Cyan, Green, Purple, Red}; -use ansi_term::{ANSIGenericString, ANSIStrings}; +use ansi_term::ANSIStrings; +use ansi_term::Colour::{Blue, Cyan, Fixed, Green, Purple, Red, Yellow}; use clap::{App, Arg, ArgMatches, SubCommand}; use git2::{self, Repository, StatusOptions}; use regex::Regex; @@ -27,7 +27,7 @@ fn repo_status(r: &Repository, detailed: bool) -> Option { if !detailed { if let Some((index_change, wt_change, conflicted, untracked)) = count_files_statuses(r) { if index_change != 0 || wt_change != 0 || conflicted != 0 || untracked != 0 { - out.push(Red.bold().paint(" *")); + out.push(Red.bold().paint("*")); } } } else { @@ -48,19 +48,19 @@ fn repo_status(r: &Repository, detailed: bool) -> Option { out.push(Green.paint(format!(" ♦ {}", index_change))); } if conflicted > 0 { - out.push(Red.paint(format!(" ✖ {}", conflicted))); + out.push(Red.paint(format!(" x {}", conflicted))); } if wt_change > 0 { - out.push(ANSIGenericString::from(format!(" ✚ {}", wt_change))); + out.push(Yellow.paint(format!(" + {}", wt_change))); } if untracked > 0 { - out.push(ANSIGenericString::from(" …")); + out.push(Fixed(245).paint(" *")); } } } if let Some(action) = get_action(r) { - out.push(Purple.paint(format!(" {}", action))); + out.push(Purple.paint(format!("{}", action))); } } @@ -192,17 +192,25 @@ fn get_action(r: &Repository) -> Option { } pub fn display(sub_matches: &ArgMatches) { - let my_path = env::current_dir().unwrap(); - let display_path = Blue.paint(shorten_path(my_path.to_str().unwrap())); + let cur_path = env::current_dir().unwrap(); + let cur_user = env::var("USER").unwrap(); - let branch = match Repository::discover(my_path) { + let display_path = Blue.paint(shorten_path(cur_path.to_str().unwrap())); + + let branch = match Repository::discover(cur_path) { Ok(repo) => repo_status(&repo, sub_matches.is_present("git-detailed")), Err(_e) => None, }; let display_branch = Cyan.paint(branch.unwrap_or_default()); println!(""); - println!("{} {}", display_path, display_branch); + println!( + "{} {} {} {}", + Purple.paint("λ"), + Green.paint(cur_user), + display_path, + display_branch + ); } pub fn cli_arguments<'a>() -> App<'a, 'a> { diff --git a/src/prompt.rs b/src/prompt.rs index fee5368..c14ed44 100644 --- a/src/prompt.rs +++ b/src/prompt.rs @@ -1,38 +1,34 @@ -use clap::{ArgMatches, App, SubCommand, Arg}; +use clap::{App, Arg, ArgMatches, SubCommand}; -const INSERT_SYMBOL:&str = "❯"; -const COMMAND_SYMBOL:&str = "⬢"; -const COMMAND_KEYMAP:&str = "vicmd"; -const NO_ERROR:&str = "0"; +const INSERT_SYMBOL: &str = "→"; +const COMMAND_SYMBOL: &str = "⬢"; +const COMMAND_KEYMAP: &str = "vicmd"; +const NO_ERROR: &str = "0"; pub fn display(sub_matches: &ArgMatches) { - let last_return_code = sub_matches.value_of("last_return_code").unwrap_or("0"); - let keymap = sub_matches.value_of("keymap").unwrap_or("US"); - - let symbol = match keymap { - COMMAND_KEYMAP => COMMAND_SYMBOL, - _ => INSERT_SYMBOL, - }; + let last_return_code = sub_matches.value_of("last_return_code").unwrap_or("0"); + let keymap = sub_matches.value_of("keymap").unwrap_or("US"); - let shell_color = match (symbol, last_return_code) { - (COMMAND_SYMBOL, _) => 3, - (_, NO_ERROR) => 5, - _ => 9, - }; + let symbol = match keymap { + COMMAND_KEYMAP => COMMAND_SYMBOL, + _ => INSERT_SYMBOL, + }; - print!("%F{{{}}}{}%f ", shell_color, symbol); + let shell_color = match (symbol, last_return_code) { + (COMMAND_SYMBOL, _) => 3, + (_, NO_ERROR) => 5, + _ => 9, + }; + + print!("%F{{{}}}{}%f ", shell_color, symbol); } pub fn cli_arguments<'a>() -> App<'a, 'a> { - SubCommand::with_name("prompt") - .arg( - Arg::with_name("last_return_code") - .short("r") - .takes_value(true) - ) - .arg( - Arg::with_name("keymap") - .short("k") - .takes_value(true) - ) + SubCommand::with_name("prompt") + .arg( + Arg::with_name("last_return_code") + .short("r") + .takes_value(true), + ) + .arg(Arg::with_name("keymap").short("k").takes_value(true)) }