mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 13:06:08 +02:00
add command g to switch shell quickly (#4014)
Signed-off-by: Tw <tw19881113@gmail.com>
This commit is contained in:
@ -177,6 +177,9 @@ impl Iterator for InternalIterator {
|
||||
CommandAction::NextShell => {
|
||||
self.context.shell_manager().next();
|
||||
}
|
||||
CommandAction::GotoShell(i) => {
|
||||
self.context.shell_manager().goto(i);
|
||||
}
|
||||
CommandAction::LeaveShell(code) => {
|
||||
self.context.shell_manager().remove_at_current();
|
||||
if self.context.shell_manager().is_empty() {
|
||||
|
@ -136,6 +136,16 @@ impl ShellManager {
|
||||
self.set_path(self.path())
|
||||
}
|
||||
|
||||
pub fn goto(&self, i: usize) {
|
||||
{
|
||||
let shell_len = self.shells.lock().len();
|
||||
if i < shell_len {
|
||||
self.current_shell.store(i, Ordering::SeqCst);
|
||||
}
|
||||
}
|
||||
self.set_path(self.path())
|
||||
}
|
||||
|
||||
pub fn homedir(&self) -> Option<PathBuf> {
|
||||
let env = self.shells.lock();
|
||||
|
||||
|
Reference in New Issue
Block a user