pub struct ShellSession {
pub name: String,
pub working_dir: PathBuf,
pub env_vars: HashMap<String, String>,
pub profile: Option<String>,
pub path_entries: Vec<String>,
pub history: Vec<HistoryEntry>,
pub shell: String,
pub active: bool,
}Expand description
A persistent shell session with environment state.
Fields§
§name: StringSession name.
working_dir: PathBufWorking directory.
env_vars: HashMap<String, String>Environment variables.
profile: Option<String>Applied environment profile.
path_entries: Vec<String>PATH entries.
history: Vec<HistoryEntry>Command history.
shell: StringShell to use.
active: boolWhether active.
Implementations§
Source§impl ShellSession
impl ShellSession
Sourcepub fn with_working_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn with_working_dir(self, dir: impl Into<PathBuf>) -> Self
Set working directory.
Sourcepub fn with_shell(self, shell: impl Into<String>) -> Self
pub fn with_shell(self, shell: impl Into<String>) -> Self
Set shell.
Sourcepub fn set_env(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn set_env(&mut self, key: impl Into<String>, value: impl Into<String>)
Set an environment variable.
Sourcepub fn remove_env(&mut self, key: &str) -> Option<String>
pub fn remove_env(&mut self, key: &str) -> Option<String>
Remove an environment variable.
Sourcepub fn add_to_path(&mut self, entry: impl Into<String>)
pub fn add_to_path(&mut self, entry: impl Into<String>)
Add a PATH entry.
Sourcepub fn record_command(
&mut self,
command: impl Into<String>,
exit_code: i32,
working_dir: impl Into<PathBuf>,
)
pub fn record_command( &mut self, command: impl Into<String>, exit_code: i32, working_dir: impl Into<PathBuf>, )
Record a command in history.
Sourcepub fn record_command_with_duration(
&mut self,
command: impl Into<String>,
exit_code: i32,
working_dir: impl Into<PathBuf>,
duration_ms: u64,
)
pub fn record_command_with_duration( &mut self, command: impl Into<String>, exit_code: i32, working_dir: impl Into<PathBuf>, duration_ms: u64, )
Record a command with duration.
Sourcepub fn recent_commands(&self, n: usize) -> &[HistoryEntry]
pub fn recent_commands(&self, n: usize) -> &[HistoryEntry]
Get recent commands.
Sourcepub fn history_len(&self) -> usize
pub fn history_len(&self) -> usize
History length.
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Clear history.
Sourcepub fn export_env_script(&self) -> String
pub fn export_env_script(&self) -> String
Export environment as shell script.
Sourcepub fn save_to_file(&self, path: &Path) -> Result<()>
pub fn save_to_file(&self, path: &Path) -> Result<()>
Save to file.
Sourcepub fn load_from_file(path: &Path) -> Result<Self>
pub fn load_from_file(path: &Path) -> Result<Self>
Load from file.
Trait Implementations§
Source§impl Clone for ShellSession
impl Clone for ShellSession
Source§fn clone(&self) -> ShellSession
fn clone(&self) -> ShellSession
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ShellSession
impl Debug for ShellSession
Source§impl<'de> Deserialize<'de> for ShellSession
impl<'de> Deserialize<'de> for ShellSession
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ShellSession
impl RefUnwindSafe for ShellSession
impl Send for ShellSession
impl Sync for ShellSession
impl Unpin for ShellSession
impl UnsafeUnpin for ShellSession
impl UnwindSafe for ShellSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more