add nop alias for ()

This commit is contained in:
Arthur Beck 2025-05-06 16:20:30 -05:00
parent 388f709394
commit 0453209025
2 changed files with 41 additions and 29 deletions

View file

@ -194,29 +194,26 @@ pub fn help(args: Vec<String>, _: String, state: &mut super::State) -> i32 {
}
println!(
"{}sesh, version {} ({})",
if state.in_mode {
"\x1b[31;1m"
} else {
""
},
if state.in_mode { "\x1b[31;1m" } else { "" },
env!("CARGO_PKG_VERSION"),
env!("TARGET")
);
println!("{}This provides a list of built-in shell commands.", if state.in_mode {
"\x1b[38;2;255;165;0m"
} else {
""
});
println!("{}Use `man sesh` to find out more about the shell in general.", if state.in_mode {
"\x1b[33;1m"
} else {
""
});
println!("{}Use `man -k' or `info' to find out more about commands not in this list.", if state.in_mode {
"\x1b[32;1m"
} else {
""
});
println!(
"{}This provides a list of built-in shell commands.",
if state.in_mode {
"\x1b[38;2;255;165;0m"
} else {
""
}
);
println!(
"{}Use `man sesh` to find out more about the shell in general.",
if state.in_mode { "\x1b[33;1m" } else { "" }
);
println!(
"{}Use `man -k' or `info' to find out more about commands not in this list.",
if state.in_mode { "\x1b[32;1m" } else { "" }
);
println!();
let mut builtins = BUILTINS;
builtins.sort_by(|v1, v2| v1.0.cmp(v2.0));
@ -235,7 +232,7 @@ pub fn help(args: Vec<String>, _: String, state: &mut super::State) -> i32 {
"\x1b[33;1m",
"\x1b[32;1m",
];
let idx = i%table.len();
let idx = i % table.len();
print!("{}", table[idx]);
}
println!("{} {}", builtin.0, builtin.2);

View file

@ -99,7 +99,7 @@ struct State {
/// sh
in_mode: bool,
/// sh
entries: usize
entries: usize,
}
unsafe impl Sync for State {}
@ -122,7 +122,7 @@ fn split_statement(statement: &str) -> Vec<String> {
if ch == ']' {
out[i].push(ch);
}
if ch == ')' && f == str_idx+1 {
if ch == ')' && f == str_idx + 1 {
out[i].push('(');
out[i].push(ch);
}
@ -398,9 +398,9 @@ fn write_prompt(state: State) -> Result<(), Box<dyn std::error::Error>> {
"\x1b[32;1m",
"\x1b[34;1m",
"\x1b[36;1m",
"\x1b[35;1m"
"\x1b[35;1m",
];
let idx = state.entries.saturating_sub(1)%table.len();
let idx = state.entries.saturating_sub(1) % table.len();
prompt += table[idx];
}
@ -434,7 +434,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
aliases: Vec::new(),
raw_term: None,
in_mode: false,
entries: 0
entries: 0,
};
state.shell_env.push(ShellVar {
name: "PROMPT1".to_string(),
@ -483,8 +483,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
eval(&options.run_before, &mut state)
}
let mut history: Vec<String> = vec![];
let mut hist_ptr: usize = 0;
let mut history: Vec<String> =
std::fs::read_to_string(std::env::home_dir().unwrap().join(".sesh_history"))
.unwrap_or_default()
.split("\n")
.map(|v| v.to_string())
.collect();
let mut hist_ptr: usize = history.len();
state.raw_term = Some(Arc::new(RwLock::new(std::io::stdout().into_raw_mode()?)));
@ -631,7 +636,17 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}
println!("\x0D");
history.push(input.clone().trim().to_string());
input = input.clone().trim().to_string();
history.push(input.clone());
std::fs::OpenOptions::new()
.create(true)
.append(true)
.open(std::env::home_dir().unwrap().join(".sesh_history"))
.unwrap()
.write_all((input.clone() + "\n").into_bytes().as_slice())
.unwrap();
hist_ptr = history.len();
state.entries += 1;