diff --git a/Cargo.lock b/Cargo.lock index d3fe21b..b3eea2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,6 +195,12 @@ version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +[[package]] +name = "shell-words" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" + [[package]] name = "sqish" version = "1.0.0" @@ -203,6 +209,7 @@ dependencies = [ "dirs", "gethostname", "regex", + "shell-words", "termion", "unicode-segmentation", "users", diff --git a/README.md b/README.md index d6d98b5..38c9aa2 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,6 @@ TODO: * Allow redirecting >> to the end of a file ? * Allow && in commands ? * Improve word jumping -* Allow bold / italic / etc in prompt -* Reduce newlines in autocompletes ## sqishrc (Config) See the included sqishrc file included for comments, and copy it as ~/.sqishrc for use (optionnal). diff --git a/sqishrc b/sqishrc index 3175aea..dfe0cc9 100644 --- a/sqishrc +++ b/sqishrc @@ -24,6 +24,11 @@ #RGB ! #RGB is defined as $RGB|red|green|blue_ #For example $RGB|108|84|30_ gives you an ugly shade of brown +# +#Styles: +#BOLD : start of a bold block +#ITA : start of an italic block +#STYLERESET : reset all styles. prompt: "$COLORLBLACK_ !$HISTNUMBER_$COLORCYAN_[$USER_@$HOSTNAME_]$RGB|125|0|125_$DIR_> $COLORRESET_" #Classic aliases, can be used in conjunction with hotkeys diff --git a/src/lib.rs b/src/lib.rs index 044aee4..833299c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -390,7 +390,7 @@ pub mod shell { //Search *&mut mycommand = replace_signs(&mycommand); let (res, list) = Search::build(&mycommand).unwrap().autocomplete(); - if list.len() > 0 { write!(stdout, "\r\n{}\r\n", list); } + if list.len() > 0 { write!(stdout, "{}", list); } mycommand.clear(); mycommand.push_str(&res); max_pos = res.len(); diff --git a/src/shell/config.rs b/src/shell/config.rs index 85a8e3c..526adb9 100644 --- a/src/shell/config.rs +++ b/src/shell/config.rs @@ -1,5 +1,5 @@ use users::{get_user_by_uid, get_current_uid}; -use termion::color; +use termion::{color, style}; use std::{env, fs}; use std::collections::HashMap; use regex::Regex; @@ -112,6 +112,7 @@ impl SqishConf { fn handle_colors(&mut self) { + //Colors let reset = format!("{}", color::Fg(color::Reset)); let green = format!("{}", color::Fg(color::Green)); let blue = format!("{}", color::Fg(color::Blue)); @@ -121,6 +122,12 @@ impl SqishConf { let cyan = format!("{}", color::Fg(color::Cyan)); let lightblack = format!("{}", color::Fg(color::LightBlack)); + //Styles + let ita = format!("{}", style::Italic); + let bold = format!("{}", style::Bold); + let stylereset = format!("{}", style::Reset); + + //Colors replace let mut prompt = self.promptline.replace("$COLORGREEN_", &green); prompt = prompt.replace("$COLORBLUE_", &blue); prompt = prompt.replace("$COLORRED_", &red); @@ -129,6 +136,11 @@ impl SqishConf { prompt = prompt.replace("$COLORCYAN_", &cyan); prompt = prompt.replace("$COLORLBLACK_", &lightblack); prompt = prompt.replace("$COLORRESET_", &reset); + + //Styles replace + prompt = prompt.replace("$ITA_", &ita); + prompt = prompt.replace("$BOLD_", &bold); + prompt = prompt.replace("$STYLERESET_", &stylereset); let promptown = prompt.to_owned(); self.promptline = promptown; }