Added an init line in sqishrc
This commit is contained in:
parent
c06afb410c
commit
0bf2c601c3
@ -3,7 +3,6 @@ Rust Shell. This is an attempt to create a simple shell in Rust, because why not
|
||||
|
||||
TODO:
|
||||
* git commit -m "message" does not work
|
||||
* Startup script section in sqishrc
|
||||
|
||||
## sqishrc (Config)
|
||||
See the included sqishrc file included, and copy it as ~/.sqishrc
|
||||
|
@ -342,6 +342,7 @@ pub mod shell {
|
||||
promptline_base: String::from("!$HISTNUMBER_$COLORGREEN_[$USER_@$HOSTNAME_]$COLORRESET_ "),
|
||||
aliases: HashMap::new(),
|
||||
hotkeys: HashMap::new(),
|
||||
init: String::new(),
|
||||
};
|
||||
let ret_line = format!("Could not build conf, got {}\
|
||||
\r\nUsing default promptline", e);
|
||||
@ -351,10 +352,14 @@ pub mod shell {
|
||||
};
|
||||
&conf.update_prompt(get_curr_history_number());
|
||||
|
||||
//Initialize
|
||||
write!(stdout, "\r\n SquiShell (sqish)--- \r\n{}", conf.promptline);
|
||||
//Initializing
|
||||
write!(stdout, "\r\n ---Sqish initializing...--- \r\n{}", conf.promptline);
|
||||
stdout.flush();
|
||||
|
||||
if conf.init != String::from("") {
|
||||
run_cmd(&mut String::from(&conf.init), &mut current_number, &mut conf, &mut stdout);
|
||||
}
|
||||
|
||||
for c in stdin.keys() {
|
||||
let k = c.unwrap();
|
||||
match k {
|
||||
|
@ -15,6 +15,7 @@ pub struct SqishConf {
|
||||
pub promptline_base: String,
|
||||
pub aliases: HashMap<String, String>,
|
||||
pub hotkeys: HashMap<String, String>,
|
||||
pub init: String,
|
||||
}
|
||||
|
||||
impl SqishConf {
|
||||
@ -42,7 +43,8 @@ impl SqishConf {
|
||||
};
|
||||
|
||||
let sqishrc = &sqishrc[0];
|
||||
let out_str = String::from(sqishrc["prompt"].as_str().unwrap());
|
||||
let out_str = String::from(sqishrc["prompt"].as_str().unwrap_or("$ "));
|
||||
let startup = String::from(sqishrc["init"].as_str().unwrap_or(""));
|
||||
|
||||
//Loading hotkeys and aliases from yaml
|
||||
//They can be empty, be careful...
|
||||
@ -57,6 +59,7 @@ impl SqishConf {
|
||||
promptline_base: out_str,
|
||||
aliases: aliases,
|
||||
hotkeys: hotkeys,
|
||||
init: startup,
|
||||
};
|
||||
|
||||
out_conf.handle_rgb();
|
||||
|
Loading…
x
Reference in New Issue
Block a user