From 095b270fea283ed0a9d147c2b154a80030f19a4c Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Tue, 6 May 2025 00:26:07 -0700 Subject: [PATCH] csh -> tcsh --- CHANGELOG.md | 2 +- README.md | 12 ++++++++++++ contrib/completions/_zoxide | 2 +- contrib/completions/zoxide.bash | 2 +- contrib/completions/zoxide.ts | 2 +- man/man1/zoxide-init.1 | 8 ++++++++ src/cmd/cmd.rs | 3 +-- src/cmd/init.rs | 4 ++-- src/shell.rs | 30 +++++++++++++++--------------- templates/{csh.txt => tcsh.txt} | 6 +++--- 10 files changed, 45 insertions(+), 26 deletions(-) rename templates/{csh.txt => tcsh.txt} (95%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d67b22..87d47ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Support for Csh. +- Support for Tcsh. - Added `--score` flag to `zoxide add`. ### Changed diff --git a/README.md b/README.md index 5e3d883..09faada 100644 --- a/README.md +++ b/README.md @@ -280,6 +280,18 @@ zoxide can be installed in 4 easy steps: +
+ Tcsh + + > Add this to the **end** of your config file (usually `~/.tcshrc`): + > + > ```sh + > zoxide init tcsh > ~/.zoxide.tcsh + > source ~/.zoxide.tcsh + > ``` + +
+
Xonsh diff --git a/contrib/completions/_zoxide b/contrib/completions/_zoxide index 3bbb5cf..2f3557f 100644 --- a/contrib/completions/_zoxide +++ b/contrib/completions/_zoxide @@ -114,7 +114,7 @@ _arguments "${_arguments_options[@]}" : \ '--help[Print help]' \ '-V[Print version]' \ '--version[Print version]' \ -':shell:(bash csh elvish fish nushell posix powershell xonsh zsh)' \ +':shell:(bash elvish fish nushell posix powershell tcsh xonsh zsh)' \ && ret=0 ;; (query) diff --git a/contrib/completions/zoxide.bash b/contrib/completions/zoxide.bash index 2601198..909bc57 100644 --- a/contrib/completions/zoxide.bash +++ b/contrib/completions/zoxide.bash @@ -173,7 +173,7 @@ _zoxide() { return 0 ;; zoxide__init) - opts="-h -V --no-cmd --cmd --hook --help --version bash csh elvish fish nushell posix powershell xonsh zsh" + opts="-h -V --no-cmd --cmd --hook --help --version bash elvish fish nushell posix powershell tcsh xonsh zsh" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 diff --git a/contrib/completions/zoxide.ts b/contrib/completions/zoxide.ts index 88f034b..9e593d0 100644 --- a/contrib/completions/zoxide.ts +++ b/contrib/completions/zoxide.ts @@ -189,12 +189,12 @@ const completion: Fig.Spec = { name: "shell", suggestions: [ "bash", - "csh", "elvish", "fish", "nushell", "posix", "powershell", + "tcsh", "xonsh", "zsh", ], diff --git a/man/man1/zoxide-init.1 b/man/man1/zoxide-init.1 index 387c318..ebf1ed1 100644 --- a/man/man1/zoxide-init.1 +++ b/man/man1/zoxide-init.1 @@ -55,6 +55,14 @@ $profile\fR in PowerShell): \fBInvoke-Expression (& { (zoxide init powershell | Out-String) })\fR .fi .TP +.B tcsh +Add this to the \fBend\fR of your config file (usually \fB~/.tcshrc\fR): +.sp +.nf + \fBzoxide init tcsh > ~/.zoxide.tcsh\fR + \fBsource ~/.zoxide.tcsh\fR +.fi +.TP .B xonsh Add this to the \fBend\fR of your config file (usually \fB~/.xonshrc\fR): .sp diff --git a/src/cmd/cmd.rs b/src/cmd/cmd.rs index 6b79c5c..d25cda3 100644 --- a/src/cmd/cmd.rs +++ b/src/cmd/cmd.rs @@ -147,14 +147,13 @@ pub enum InitHook { #[derive(ValueEnum, Clone, Debug)] pub enum InitShell { Bash, - #[clap(alias = "tcsh")] - Csh, Elvish, Fish, Nushell, #[clap(alias = "ksh")] Posix, Powershell, + Tcsh, Xonsh, Zsh, } diff --git a/src/cmd/init.rs b/src/cmd/init.rs index 6c15831..506bd29 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -6,7 +6,7 @@ use rinja::Template; use crate::cmd::{Init, InitShell, Run}; use crate::config; use crate::error::BrokenPipeHandler; -use crate::shell::{Bash, Csh, Elvish, Fish, Nushell, Opts, Posix, Powershell, Xonsh, Zsh}; +use crate::shell::{Bash, Elvish, Fish, Nushell, Opts, Posix, Powershell, Tcsh, Xonsh, Zsh}; impl Run for Init { fn run(&self) -> Result<()> { @@ -17,12 +17,12 @@ impl Run for Init { let source = match self.shell { InitShell::Bash => Bash(opts).render(), - InitShell::Csh => Csh(opts).render(), InitShell::Elvish => Elvish(opts).render(), InitShell::Fish => Fish(opts).render(), InitShell::Nushell => Nushell(opts).render(), InitShell::Posix => Posix(opts).render(), InitShell::Powershell => Powershell(opts).render(), + InitShell::Tcsh => Tcsh(opts).render(), InitShell::Xonsh => Xonsh(opts).render(), InitShell::Zsh => Zsh(opts).render(), } diff --git a/src/shell.rs b/src/shell.rs index 78bf2f3..83243d8 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -24,12 +24,12 @@ macro_rules! make_template { } make_template!(Bash, "bash.txt"); -make_template!(Csh, "csh.txt"); make_template!(Elvish, "elvish.txt"); make_template!(Fish, "fish.txt"); make_template!(Nushell, "nushell.txt"); make_template!(Posix, "posix.txt"); make_template!(Powershell, "powershell.txt"); +make_template!(Tcsh, "tcsh.txt"); make_template!(Xonsh, "xonsh.txt"); make_template!(Zsh, "zsh.txt"); @@ -94,20 +94,6 @@ mod tests { .stderr(""); } - #[apply(opts)] - fn csh_tcsh(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) { - let opts = Opts { cmd, hook, echo, resolve_symlinks }; - let source = Csh(&opts).render().unwrap(); - - Command::new("tcsh") - .args(["-e", "-f", "-s"]) - .write_stdin(source) - .assert() - .success() - .stdout("") - .stderr(""); - } - #[apply(opts)] fn elvish_elvish(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) { let opts = Opts { cmd, hook, echo, resolve_symlinks }; @@ -263,6 +249,20 @@ mod tests { .stderr(""); } + #[apply(opts)] + fn tcsh_tcsh(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) { + let opts = Opts { cmd, hook, echo, resolve_symlinks }; + let source = Tcsh(&opts).render().unwrap(); + + Command::new("tcsh") + .args(["-e", "-f", "-s"]) + .write_stdin(source) + .assert() + .success() + .stdout("") + .stderr(""); + } + #[apply(opts)] fn xonsh_black(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) { let opts = Opts { cmd, hook, echo, resolve_symlinks }; diff --git a/templates/csh.txt b/templates/tcsh.txt similarity index 95% rename from templates/csh.txt rename to templates/tcsh.txt index 1145052..b0559a0 100644 --- a/templates/csh.txt +++ b/templates/tcsh.txt @@ -68,7 +68,7 @@ alias {{cmd}}i __zoxide_zi {%- endmatch %} {{ section }} -# To initialize zoxide, add this to your shell configuration file (usually ~/.cshrc or ~/.tcshrc): +# To initialize zoxide, add this to your shell configuration file (usually ~/.tcshrc): # -# zoxide init csh > ~/.zoxide.csh -# source ~/.zoxide.csh +# zoxide init tcsh > ~/.zoxide.tcsh +# source ~/.zoxide.tcsh