From 2d8c8d71fc990707c0422a214004901f51595087 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 9 Jul 2026 05:22:13 +0000 Subject: [PATCH] Port zsh shell helpers to Fish functions Add cdgr, fpr, serve, jump, xin, nonascii, and syspip/syspip3 as Fish autoload functions mirroring ~/.shell/aliases.sh behavior. Co-authored-by: Huy Pham --- README.md | 2 +- dot_config/fish/functions/cdgr.fish | 3 +++ dot_config/fish/functions/fpr.fish | 25 +++++++++++++++++++++++++ dot_config/fish/functions/jump.fish | 3 +++ dot_config/fish/functions/nonascii.fish | 3 +++ dot_config/fish/functions/serve.fish | 5 +++++ dot_config/fish/functions/syspip.fish | 7 +++++++ dot_config/fish/functions/xin.fish | 5 +++++ 8 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 dot_config/fish/functions/cdgr.fish create mode 100644 dot_config/fish/functions/fpr.fish create mode 100644 dot_config/fish/functions/jump.fish create mode 100644 dot_config/fish/functions/nonascii.fish create mode 100644 dot_config/fish/functions/serve.fish create mode 100644 dot_config/fish/functions/syspip.fish create mode 100644 dot_config/fish/functions/xin.fish diff --git a/README.md b/README.md index e895c35..c8d96db 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Or your usual **`dfu`** alias if it wraps the same steps. ## Layout notes -- **Fish** (`dot_config/fish/`): `conf.d/` snippets (PATH from **`00-chezmoi-path.fish.tmpl`**, env, abbreviations, dircolors, Catppuccin theme, vi bindings, secrets) and **`functions/`** for `dfu`, `load_secret`, `cdgr`, `up`, helpers, plus **`fish_prompt`** / **`fish_right_prompt`** (cwd + `USER at <~/.name>` + `fish_git_prompt`). Not ported from zsh: async right-prompt, `tog` / `vshow` / `vmultiline`. +- **Fish** (`dot_config/fish/`): `conf.d/` snippets (PATH from **`00-path.fish.tmpl`**, env, abbreviations, Catppuccin theme, vi bindings, secrets) and **`functions/`** for `dfu`, `load_secret`, `mcd`, `peek`, `up`, `cdgr`, `fpr`, `serve`, `jump`, `xin`, `nonascii`, `syspip`/`syspip3`. Zsh-only via `~/.shell/aliases.sh`: screen `cd` hack, `syspip2`. Not ported from zsh: async right-prompt, `tog` / `vshow` / `vmultiline`. - **Vim externals** ([`.chezmoiexternal.toml`](.chezmoiexternal.toml)): [vim-polyglot](https://github.com/sheerun/vim-polyglot) for bundled syntax; [vim-go](https://github.com/fatih/vim-go) with **`g:polyglot_disabled = ['go']`** in `dot_vimrc` so Go stays on vim-go. Separate trees for [preservim/nerdtree](https://github.com/preservim/nerdtree), [lightline.vim](https://github.com/itchyny/lightline.vim), [material.vim](https://github.com/kaicataldo/material.vim), [incsearch.vim](https://github.com/haya14busa/incsearch.vim). Dircolors: [nordtheme/dircolors](https://github.com/nordtheme/dircolors) under `~/.shell/plugins/nord-dircolors/`. - **`dot_zshrc.tmpl`**: main zsh init (PATH, Homebrew on macOS, shared `~/.shell` and `~/.zsh` bits). Optional **`~/.zshrc.local`** is sourced last for machine-only overrides (not in this repo). - **`dot_hammerspoon/`** is skipped on non-macOS via **`.chezmoiignore.tmpl`**. diff --git a/dot_config/fish/functions/cdgr.fish b/dot_config/fish/functions/cdgr.fish new file mode 100644 index 0000000..6636e67 --- /dev/null +++ b/dot_config/fish/functions/cdgr.fish @@ -0,0 +1,3 @@ +function cdgr + cd (git root) +end diff --git a/dot_config/fish/functions/fpr.fish b/dot_config/fish/functions/fpr.fish new file mode 100644 index 0000000..02220dd --- /dev/null +++ b/dot_config/fish/functions/fpr.fish @@ -0,0 +1,25 @@ +function fpr + if not git rev-parse --git-dir >/dev/null 2>&1 + echo 'error: fpr must be executed from within a git repository' >&2 + return 1 + end + + cdgr; or return + + set -l repo user branch + switch (count $argv) + case 2 + set repo (basename $PWD) + set user $argv[1] + set branch $argv[2] + case 3 + set repo $argv[1] + set user $argv[2] + set branch $argv[3] + case '*' + echo 'Usage: fpr [repo] username branch' >&2 + return 1 + end + + git fetch git@github.com:$user/$repo $branch:$user/$branch +end diff --git a/dot_config/fish/functions/jump.fish b/dot_config/fish/functions/jump.fish new file mode 100644 index 0000000..ce90ec2 --- /dev/null +++ b/dot_config/fish/functions/jump.fish @@ -0,0 +1,3 @@ +function jump + cd (dirname $argv[1]) +end diff --git a/dot_config/fish/functions/nonascii.fish b/dot_config/fish/functions/nonascii.fish new file mode 100644 index 0000000..eb1a911 --- /dev/null +++ b/dot_config/fish/functions/nonascii.fish @@ -0,0 +1,3 @@ +function nonascii + env LC_ALL=C grep -n '[^[:print:][:space:]]' $argv[1] +end diff --git a/dot_config/fish/functions/serve.fish b/dot_config/fish/functions/serve.fish new file mode 100644 index 0000000..e660236 --- /dev/null +++ b/dot_config/fish/functions/serve.fish @@ -0,0 +1,5 @@ +function serve + set -l port 8080 + test (count $argv) -ge 1; and set port $argv[1] + ruby -run -e httpd . -p $port +end diff --git a/dot_config/fish/functions/syspip.fish b/dot_config/fish/functions/syspip.fish new file mode 100644 index 0000000..2e129af --- /dev/null +++ b/dot_config/fish/functions/syspip.fish @@ -0,0 +1,7 @@ +function syspip + env PIP_REQUIRE_VIRTUALENV= pip $argv +end + +function syspip3 + env PIP_REQUIRE_VIRTUALENV= pip3 $argv +end diff --git a/dot_config/fish/functions/xin.fish b/dot_config/fish/functions/xin.fish new file mode 100644 index 0000000..cf3f4cc --- /dev/null +++ b/dot_config/fish/functions/xin.fish @@ -0,0 +1,5 @@ +function xin + cd $argv[1]; or return + set -e argv[1] + command $argv +end