v1, champagne
This commit is contained in:
parent
08f80a57c1
commit
2a0866ab64
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "sqish"
|
name = "sqish"
|
||||||
version = "0.1.0"
|
version = "1.0.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
|
@ -11,7 +11,7 @@ See the included sqishrc.yaml.example file included, and copy it as ~/.sqishrc.y
|
|||||||
## Built-in shortcuts
|
## Built-in shortcuts
|
||||||
### As Hotkeys
|
### As Hotkeys
|
||||||
Some shortcuts are built in. They may be unique to Sqish or be copied from Zsh for example.
|
Some shortcuts are built in. They may be unique to Sqish or be copied from Zsh for example.
|
||||||
* Ctrl+Q : Quits the shell immediatly
|
* Ctrl+Q or Ctrl+D : Quits the shell immediatly
|
||||||
* Ctrl+U : Clears currently written line
|
* Ctrl+U : Clears currently written line
|
||||||
* Alt+. : Appends the last word from previous command
|
* Alt+. : Appends the last word from previous command
|
||||||
* Ctrl+A : Jumps to the end of the line
|
* Ctrl+A : Jumps to the end of the line
|
||||||
|
30
src/lib.rs
30
src/lib.rs
@ -108,25 +108,9 @@ pub mod shell {
|
|||||||
let output = child
|
let output = child
|
||||||
.wait_with_output()
|
.wait_with_output()
|
||||||
.expect("Failed to wait on child");
|
.expect("Failed to wait on child");
|
||||||
//RawTerminal::activate_raw_mode(stdout);
|
|
||||||
|
|
||||||
// let output = Command::new(command)
|
|
||||||
// .args(args)
|
|
||||||
// .stdin(stdin)
|
|
||||||
// .output();
|
|
||||||
|
|
||||||
// let command_result = match output {
|
|
||||||
// Ok(o) => o,
|
|
||||||
// Err(e) => {
|
|
||||||
// eprintln!("\r\nGot error {}", e);
|
|
||||||
// return String::from("!");
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// let _ = &mut resultat.push_str(str::from_utf8(&command_result.stdout)
|
|
||||||
let status = output.status
|
let status = output.status
|
||||||
.code()
|
.code()
|
||||||
.expect("Could not get code")
|
.expect("Could not get retcode")
|
||||||
.to_string();
|
.to_string();
|
||||||
previous_command = None;
|
previous_command = None;
|
||||||
let format_res = format!("{}...Exit: {}\r\n",
|
let format_res = format!("{}...Exit: {}\r\n",
|
||||||
@ -248,12 +232,14 @@ pub mod shell {
|
|||||||
*current_number += 1;
|
*current_number += 1;
|
||||||
} else if mycommand == &String::from("exit") {
|
} else if mycommand == &String::from("exit") {
|
||||||
write!(stdout, "\r\n Sayonara \r\n");
|
write!(stdout, "\r\n Sayonara \r\n");
|
||||||
|
RawTerminal::suspend_raw_mode(&stdout);
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
} else {
|
} else {
|
||||||
conf.update_prompt(get_curr_history_number());
|
conf.update_prompt(get_curr_history_number());
|
||||||
write!(stdout, "\r\n{}", conf.promptline).unwrap();
|
write!(stdout, "\r\n{}", conf.promptline).unwrap();
|
||||||
stdout.flush();
|
|
||||||
}
|
}
|
||||||
|
stdout.flush();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_letter(mycommand: &mut String, current_pos: &mut usize, max_pos: &mut usize, c: char) {
|
fn write_letter(mycommand: &mut String, current_pos: &mut usize, max_pos: &mut usize, c: char) {
|
||||||
@ -354,7 +340,8 @@ pub mod shell {
|
|||||||
&mut stdout);
|
&mut stdout);
|
||||||
},
|
},
|
||||||
|
|
||||||
Key::Ctrl('q') => {
|
Key::Ctrl('q'|'d') => {
|
||||||
|
RawTerminal::suspend_raw_mode(&stdout);
|
||||||
writeln!(stdout, "\r\n Sayonara \r\n");
|
writeln!(stdout, "\r\n Sayonara \r\n");
|
||||||
break;
|
break;
|
||||||
},
|
},
|
||||||
@ -484,7 +471,7 @@ pub mod shell {
|
|||||||
|
|
||||||
Key::Alt(x) => {
|
Key::Alt(x) => {
|
||||||
match x {
|
match x {
|
||||||
'a'..='y' => {
|
'a'..='z' => {
|
||||||
let x = String::from(x);
|
let x = String::from(x);
|
||||||
if conf.hotkeys.contains_key(&x) {
|
if conf.hotkeys.contains_key(&x) {
|
||||||
let hotcmd = &conf.hotkeys[&x].clone();
|
let hotcmd = &conf.hotkeys[&x].clone();
|
||||||
@ -506,9 +493,6 @@ pub mod shell {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'z' => {
|
|
||||||
print!("Z");
|
|
||||||
},
|
|
||||||
'.' => {
|
'.' => {
|
||||||
append_prev_arg(&mut mycommand, &mut current_pos, &mut max_pos);
|
append_prev_arg(&mut mycommand, &mut current_pos, &mut max_pos);
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user