mirror of
https://github.com/nushell/nushell.git
synced 2025-07-01 07:00:37 +02:00
Make g -
switch to the last used shell (#6249)
* Make `g -` switch to the last used shell Related #6223 Signed-off-by: nibon7 <nibon7@163.com> * simplify error handling Signed-off-by: nibon7 <nibon7@163.com> * update NUSHELL_LAST_SHELL environment Signed-off-by: nibon7 <nibon7@163.com> * add test Signed-off-by: nibon7 <nibon7@163.com> * fix description Signed-off-by: nibon7 <nibon7@163.com>
This commit is contained in:
@ -395,9 +395,23 @@ pub fn evaluate_repl(
|
||||
0
|
||||
};
|
||||
|
||||
let last_shell = stack.get_env_var(engine_state, "NUSHELL_LAST_SHELL");
|
||||
let last_shell = if let Some(v) = last_shell {
|
||||
v.as_integer().unwrap_or_default() as usize
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
shells[current_shell] = Value::String { val: path, span };
|
||||
|
||||
stack.add_env_var("NUSHELL_SHELLS".into(), Value::List { vals: shells, span });
|
||||
stack.add_env_var(
|
||||
"NUSHELL_LAST_SHELL".into(),
|
||||
Value::Int {
|
||||
val: last_shell as i64,
|
||||
span,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
trace!("eval source: {}", s);
|
||||
|
||||
|
Reference in New Issue
Block a user