Skip to content

Commit

Permalink
set a default prompt prefix
Browse files Browse the repository at this point in the history
The 'prompt_prefix' option has had a while to bake
and I have not gotten any bikeshedding suggestions
beyond the one I've been using, so this patch
sets a new default prompt prefix. Users should no
longer need to worry about adding shell config to
make their prompt indicate they are in a shpool
session, they should get it for free from now on.

This change can be disabled by setting prompt_prefix=""
in the config file.
  • Loading branch information
ethanpailes committed Mar 28, 2024
1 parent 510817b commit d746041
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libshpool/src/daemon/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use crate::daemon::exit_notify::ExitNotifier;
const STDERR_FD: i32 = 2;
const DEFAULT_INITIAL_SHELL_PATH: &str = "/usr/bin:/bin:/usr/sbin:/sbin";
const DEFAULT_OUTPUT_SPOOL_LINES: usize = 500;
const DEFAULT_PROMPT_PREFIX: &str = "shpool:$SHPOOL_SESSION_NAME ";

pub struct Server {
config: config::Config,
Expand Down Expand Up @@ -626,7 +627,8 @@ impl Server {
});

// inject the prompt prefix, if any
let prompt_prefix = self.config.prompt_prefix.clone().unwrap_or(String::from(""));
let prompt_prefix =
self.config.prompt_prefix.clone().unwrap_or(String::from(DEFAULT_PROMPT_PREFIX));
if let Some(shell_basename) = shell_basename {
if !prompt_prefix.is_empty() {
if let Err(err) =
Expand Down
1 change: 1 addition & 0 deletions shpool/tests/data/custom_detach_keybinding.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ norc = true
noecho = true
shell = "/bin/bash"
session_restore_mode = "simple"
prompt_prefix = ""

[env]
PS1 = "prompt> "
Expand Down
1 change: 1 addition & 0 deletions shpool/tests/data/disable_symlink_ssh_auth_sock.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ noecho = true
shell = "/bin/bash"
nosymlink_ssh_auth_sock = true
session_restore_mode = "simple"
prompt_prefix = ""

[env]
PS1 = "prompt> "
Expand Down
1 change: 1 addition & 0 deletions shpool/tests/data/forward_env.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ norc = true
noecho = true
shell = "/bin/bash"
session_restore_mode = "simple"
prompt_prefix = ""

forward_env = ["FOO", "BAR"]

Expand Down
1 change: 1 addition & 0 deletions shpool/tests/data/long_noop_keybinding.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ norc = true
noecho = true
shell = "/bin/bash"
session_restore_mode = "simple"
prompt_prefix = ""

[env]
PS1 = "prompt> "
Expand Down
1 change: 1 addition & 0 deletions shpool/tests/data/no_etc_environment.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ noecho = true
noread_etc_environment = true
shell = "/bin/bash"
session_restore_mode = "simple"
prompt_prefix = ""

[env]
PS1 = "prompt> "
Expand Down
1 change: 1 addition & 0 deletions shpool/tests/data/norc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ norc = true
noecho = true
shell = "/bin/bash"
session_restore_mode = "simple"
prompt_prefix = ""

[env]
PS1 = "prompt> "
Expand Down
1 change: 1 addition & 0 deletions shpool/tests/data/restore_lines.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ norc = true
noecho = true
shell = "/bin/bash"
session_restore_mode = { lines = 2 }
prompt_prefix = ""

[env]
PS1 = "prompt> "
Expand Down
1 change: 1 addition & 0 deletions shpool/tests/data/restore_many_lines.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ norc = true
noecho = true
shell = "/bin/bash"
session_restore_mode = { lines = 5000 }
prompt_prefix = ""

[env]
PS1 = "prompt> "
Expand Down
1 change: 1 addition & 0 deletions shpool/tests/data/restore_screen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ norc = true
noecho = true
shell = "/bin/bash"
session_restore_mode = "screen"
prompt_prefix = ""

[env]
PS1 = "prompt> "
Expand Down
1 change: 1 addition & 0 deletions shpool/tests/data/user_env.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ norc = true
noecho = true
shell = "/bin/bash"
session_restore_mode = "simple"
prompt_prefix = ""

[env]
PS1 = "prompt> "
Expand Down

0 comments on commit d746041

Please sign in to comment.