csh -> tcsh

This commit is contained in:
Ajeet D'Souza 2025-05-06 00:26:07 -07:00
parent 09aa626a86
commit 095b270fea
10 changed files with 45 additions and 26 deletions

View file

@ -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

View file

@ -280,6 +280,18 @@ zoxide can be installed in 4 easy steps:
</details>
<details>
<summary>Tcsh</summary>
> Add this to the <ins>**end**</ins> of your config file (usually `~/.tcshrc`):
>
> ```sh
> zoxide init tcsh > ~/.zoxide.tcsh
> source ~/.zoxide.tcsh
> ```
</details>
<details>
<summary>Xonsh</summary>

View file

@ -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)

View file

@ -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

View file

@ -189,12 +189,12 @@ const completion: Fig.Spec = {
name: "shell",
suggestions: [
"bash",
"csh",
"elvish",
"fish",
"nushell",
"posix",
"powershell",
"tcsh",
"xonsh",
"zsh",
],

View file

@ -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

View file

@ -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,
}

View file

@ -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(),
}

View file

@ -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 };

View file

@ -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