Fixed line returns
This commit is contained in:
parent
ed5d405649
commit
c9eb3b90df
@ -1,12 +1,6 @@
|
|||||||
# Sqish
|
# Sqish
|
||||||
Rust Shell. This is an attempt to create a simple shell in Rust, because why not.
|
Rust Shell. This is an attempt to create a simple shell in Rust, because why not.
|
||||||
|
|
||||||
TO DO:
|
|
||||||
* Implement Alt+z cancels last hotkey (meh),
|
|
||||||
* rc file shoudl probably just be called .sqishrc, and history .sqishrc.hist
|
|
||||||
* Typing vim aaa and then up arrow does not work properly ? It seems to get empty history lines
|
|
||||||
* Have a "Command not found" without having to display the previous return code
|
|
||||||
|
|
||||||
## sqishrc (Config)
|
## sqishrc (Config)
|
||||||
See the included sqishrc.yaml.example file included, and copy it as ~/.sqishrc.yaml
|
See the included sqishrc.yaml.example file included, and copy it as ~/.sqishrc.yaml
|
||||||
|
|
||||||
|
12
src/lib.rs
12
src/lib.rs
@ -101,7 +101,7 @@ pub mod shell {
|
|||||||
.spawn() {
|
.spawn() {
|
||||||
Ok(h) => h,
|
Ok(h) => h,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let err_string = format!("Command not found : {}\r\n", command);
|
let err_string = format!("Not found : {}", command);
|
||||||
return String::from(err_string);
|
return String::from(err_string);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -215,19 +215,19 @@ pub mod shell {
|
|||||||
if conf.aliases.contains_key(mycommand) {
|
if conf.aliases.contains_key(mycommand) {
|
||||||
*mycommand = conf.aliases[mycommand].clone();
|
*mycommand = conf.aliases[mycommand].clone();
|
||||||
}
|
}
|
||||||
if (mycommand != &String::from("\n")) && (mycommand != &String::from("exit")) {
|
if (mycommand != &String::from("")) && (mycommand != &String::from("exit")) {
|
||||||
let comm = replace_signs(&mycommand);
|
let comm = replace_signs(&mycommand);
|
||||||
RawTerminal::suspend_raw_mode(&stdout);
|
RawTerminal::suspend_raw_mode(&stdout);
|
||||||
let res = handle_input(&comm);
|
let res = handle_input(&comm);
|
||||||
RawTerminal::activate_raw_mode(&stdout);
|
RawTerminal::activate_raw_mode(&stdout);
|
||||||
mycommand.clear();
|
mycommand.clear();
|
||||||
for line in res.split('\n') {
|
for line in res.split("\r\n") {
|
||||||
if line != "\r" {
|
if line != "" && line.starts_with('N'){
|
||||||
write!(stdout, "\r\n{}", line);
|
write!(stdout, "{}\r\n", line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conf.update_prompt(get_curr_history_number());
|
conf.update_prompt(get_curr_history_number());
|
||||||
write!(stdout, "\r\n{}", conf.promptline).unwrap();
|
write!(stdout, "{}", conf.promptline).unwrap();
|
||||||
stdout.flush();
|
stdout.flush();
|
||||||
*current_number += 1;
|
*current_number += 1;
|
||||||
} else if mycommand == &String::from("exit") {
|
} else if mycommand == &String::from("exit") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user