Add tty working dir and hold
This commit is contained in:
parent
bf66f31735
commit
fa744071f8
3 changed files with 56 additions and 5 deletions
|
|
@ -23,6 +23,9 @@ tab-title-description = Override the default tab title
|
||||||
add-profile = Add profile
|
add-profile = Add profile
|
||||||
new-profile = New profile
|
new-profile = New profile
|
||||||
make-default = Make default
|
make-default = Make default
|
||||||
|
working-directory = Working directory
|
||||||
|
hold = Hold
|
||||||
|
remain-open = Remain open after child process exits.
|
||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
settings = Settings
|
settings = Settings
|
||||||
|
|
|
||||||
|
|
@ -188,6 +188,10 @@ pub struct Profile {
|
||||||
pub syntax_theme_light: String,
|
pub syntax_theme_light: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub tab_title: String,
|
pub tab_title: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub working_directory: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub hold: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Profile {
|
impl Default for Profile {
|
||||||
|
|
@ -198,6 +202,8 @@ impl Default for Profile {
|
||||||
syntax_theme_dark: COSMIC_THEME_DARK.to_string(),
|
syntax_theme_dark: COSMIC_THEME_DARK.to_string(),
|
||||||
syntax_theme_light: COSMIC_THEME_LIGHT.to_string(),
|
syntax_theme_light: COSMIC_THEME_LIGHT.to_string(),
|
||||||
tab_title: String::new(),
|
tab_title: String::new(),
|
||||||
|
working_directory: String::new(),
|
||||||
|
hold: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
52
src/main.rs
52
src/main.rs
|
|
@ -291,7 +291,9 @@ pub enum Message {
|
||||||
PasteValue(Option<segmented_button::Entity>, String),
|
PasteValue(Option<segmented_button::Entity>, String),
|
||||||
ProfileCollapse(ProfileId),
|
ProfileCollapse(ProfileId),
|
||||||
ProfileCommand(ProfileId, String),
|
ProfileCommand(ProfileId, String),
|
||||||
|
ProfileDirectory(ProfileId, String),
|
||||||
ProfileExpand(ProfileId),
|
ProfileExpand(ProfileId),
|
||||||
|
ProfileHold(ProfileId, bool),
|
||||||
ProfileName(ProfileId, String),
|
ProfileName(ProfileId, String),
|
||||||
ProfileNew,
|
ProfileNew,
|
||||||
ProfileOpen(ProfileId),
|
ProfileOpen(ProfileId),
|
||||||
|
|
@ -849,6 +851,16 @@ impl App {
|
||||||
])
|
])
|
||||||
.spacing(space_xxxs)
|
.spacing(space_xxxs)
|
||||||
.into(),
|
.into(),
|
||||||
|
widget::column::with_children(vec![
|
||||||
|
widget::text(fl!("working-directory")).into(),
|
||||||
|
widget::text_input("", &profile.working_directory)
|
||||||
|
.on_input(move |text| {
|
||||||
|
Message::ProfileDirectory(profile_id, text)
|
||||||
|
})
|
||||||
|
.into(),
|
||||||
|
])
|
||||||
|
.spacing(space_xxxs)
|
||||||
|
.into(),
|
||||||
widget::column::with_children(vec![
|
widget::column::with_children(vec![
|
||||||
widget::text(fl!("tab-title")).into(),
|
widget::text(fl!("tab-title")).into(),
|
||||||
widget::text_input("", &profile.tab_title)
|
widget::text_input("", &profile.tab_title)
|
||||||
|
|
@ -899,11 +911,28 @@ impl App {
|
||||||
.add(
|
.add(
|
||||||
widget::settings::item::builder(fl!("make-default")).control(
|
widget::settings::item::builder(fl!("make-default")).control(
|
||||||
widget::toggler(
|
widget::toggler(
|
||||||
"".to_string(),
|
None,
|
||||||
self.get_default_profile().is_some_and(|p| p == profile_id),
|
self.get_default_profile().is_some_and(|p| p == profile_id),
|
||||||
move |t| Message::UpdateDefaultProfile((t, profile_id)),
|
move |t| Message::UpdateDefaultProfile((t, profile_id)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
.add(
|
||||||
|
widget::row::with_children(vec![
|
||||||
|
widget::column::with_children(vec![
|
||||||
|
widget::text(fl!("hold")).into(),
|
||||||
|
widget::text::caption(fl!("remain-open")).into(),
|
||||||
|
])
|
||||||
|
.spacing(space_xxxs)
|
||||||
|
.into(),
|
||||||
|
widget::horizontal_space(Length::Fill).into(),
|
||||||
|
widget::toggler(None, profile.hold, move |t| {
|
||||||
|
Message::ProfileHold(profile_id, t)
|
||||||
|
})
|
||||||
|
.into(),
|
||||||
|
])
|
||||||
|
.align_items(Alignment::Center)
|
||||||
|
.padding([0, space_s]),
|
||||||
);
|
);
|
||||||
|
|
||||||
let padding = Padding {
|
let padding = Padding {
|
||||||
|
|
@ -1164,12 +1193,13 @@ impl App {
|
||||||
shell = Some(tty::Shell::new(command, args));
|
shell = Some(tty::Shell::new(command, args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let working_directory = (!profile.working_directory.is_empty())
|
||||||
|
.then(|| profile.working_directory.clone().into());
|
||||||
|
|
||||||
let options = tty::Options {
|
let options = tty::Options {
|
||||||
shell,
|
shell,
|
||||||
//TODO: configurable working directory?
|
working_directory,
|
||||||
working_directory: None,
|
hold: profile.hold,
|
||||||
//TODO: configurable hold (keep open when child exits)?
|
|
||||||
hold: false,
|
|
||||||
env: HashMap::new(),
|
env: HashMap::new(),
|
||||||
};
|
};
|
||||||
let tab_title_override = if !profile.tab_title.is_empty() {
|
let tab_title_override = if !profile.tab_title.is_empty() {
|
||||||
|
|
@ -1891,9 +1921,21 @@ impl Application for App {
|
||||||
return self.save_profiles();
|
return self.save_profiles();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::ProfileDirectory(profile_id, text) => {
|
||||||
|
if let Some(profile) = self.config.profiles.get_mut(&profile_id) {
|
||||||
|
profile.working_directory = text;
|
||||||
|
return self.save_profiles();
|
||||||
|
}
|
||||||
|
}
|
||||||
Message::ProfileExpand(profile_id) => {
|
Message::ProfileExpand(profile_id) => {
|
||||||
self.profile_expanded = Some(profile_id);
|
self.profile_expanded = Some(profile_id);
|
||||||
}
|
}
|
||||||
|
Message::ProfileHold(profile_id, hold) => {
|
||||||
|
if let Some(profile) = self.config.profiles.get_mut(&profile_id) {
|
||||||
|
profile.hold = hold;
|
||||||
|
return self.save_profiles();
|
||||||
|
}
|
||||||
|
}
|
||||||
Message::ProfileName(profile_id, text) => {
|
Message::ProfileName(profile_id, text) => {
|
||||||
if let Some(profile) = self.config.profiles.get_mut(&profile_id) {
|
if let Some(profile) = self.config.profiles.get_mut(&profile_id) {
|
||||||
profile.name = text;
|
profile.name = text;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue