summaryrefslogtreecommitdiffstats
path: root/src/init
diff options
context:
space:
mode:
authorVivek Malneedi <vivekmalneedi@gmail.com>2021-02-27 13:55:27 -0500
committerGitHub <noreply@github.com>2021-02-27 19:55:27 +0100
commitd21400a4784e17b7a4afe110155c01717f835388 (patch)
treefad57a93c82b1e6b1ec32cbf55a0a9137145ab8f /src/init
parentce2f844a2f5cb3a8bb12ce16acf3bcb9aaff5255 (diff)
feat: add support for tcsh (#2288)
* feat: add support for tcsh * add tcsh to install.sh install message * list tcsh in bug_report.rs and main.rs * quote starship path Co-authored-by: David Knaack <davidkna@users.noreply.github.com> * fix job count * add tcsh support to shell module * fix STARSHIP_START_TIME undefined error * preserve existing user precmd and postcmd, remove jobs support * remove unnecessary parentheses * minor script improvement * removes parens from install script message * Update docs/config/README.md Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com> Co-authored-by: David Knaack <davidkna@users.noreply.github.com> Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
Diffstat (limited to 'src/init')
-rw-r--r--src/init/mod.rs10
-rw-r--r--src/init/starship.tcsh9
2 files changed, 19 insertions, 0 deletions
diff --git a/src/init/mod.rs b/src/init/mod.rs
index a06bf32d7..be1d228f0 100644
--- a/src/init/mod.rs
+++ b/src/init/mod.rs
@@ -173,6 +173,13 @@ fi"#,
);
Some(script)
}
+ Some("tcsh") => {
+ let script = format!(
+ r#"eval "`("{}" init tcsh --print-full-init)`""#,
+ starship.sprint_posix()?
+ );
+ Some(script)
+ }
None => {
println!(
"Invalid shell name provided: {}\\n\
@@ -212,6 +219,7 @@ pub fn init_main(shell_name: &str) -> io::Result<()> {
"powershell" => print_script(PWSH_INIT, &starship_path.sprint()?),
"ion" => print_script(ION_INIT, &starship_path.sprint()?),
"elvish" => print_script(ELVISH_INIT, &starship_path.sprint_posix()?),
+ "tcsh" => print_script(TCSH_INIT, &starship_path.sprint_posix()?),
_ => {
println!(
"printf \"Shell name detection failed on phase two init.\\n\
@@ -255,3 +263,5 @@ const PWSH_INIT: &str = include_str!("starship.ps1");
const ION_INIT: &str = include_str!("starship.ion");
const ELVISH_INIT: &str = include_str!("starship.elv");
+
+const TCSH_INIT: &str = include_str!("starship.tcsh");
diff --git a/src/init/starship.tcsh b/src/init/starship.tcsh
new file mode 100644
index 000000000..7d4b4b9a0
--- /dev/null
+++ b/src/init/starship.tcsh
@@ -0,0 +1,9 @@
+setenv STARSHIP_SHELL tcsh;
+setenv STARSHIP_SESSION_KEY `::STARSHIP:: session`;
+set USER_PRECMD = "`alias precmd`";
+set USER_POSTCMD = "`alias postcmd`";
+set STARSHIP_PRECMD = 'set STARSHIP_CMD_STATUS = $status;set STARSHIP_PATH = ::STARSHIP::;set STARSHIP_END_TIME = `$STARSHIP_PATH time`;set STARSHIP_DURATION = 0;if ( $STARSHIP_START_TIME != -1 ) @ STARSHIP_DURATION = $STARSHIP_END_TIME - $STARSHIP_START_TIME;set prompt = "`$STARSHIP_PATH prompt --status $STARSHIP_CMD_STATUS --cmd-duration $STARSHIP_DURATION`";set STARSHIP_START_TIME = -1';
+set STARSHIP_POSTCMD = 'set STARSHIP_START_TIME = `::STARSHIP:: time`';
+alias precmd "$STARSHIP_PRECMD;$USER_PRECMD";
+alias postcmd "$STARSHIP_POSTCMD;$USER_POSTCMD";
+set STARSHIP_START_TIME = `::STARSHIP:: time`;