Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`**.
Expand Down
3 changes: 3 additions & 0 deletions dot_config/fish/functions/cdgr.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function cdgr
cd (git root)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using git root is not a standard Git command and relies on a custom alias that may not be configured on all systems. Additionally, if the command fails or is run outside of a Git repository, it outputs nothing to stdout, causing cd to be executed with no arguments, which unexpectedly changes the directory to $HOME.

Using git rev-parse --show-toplevel is the standard, portable way to find the repository root, and we should verify that a path was returned before attempting to change directories.

    set -l root (git rev-parse --show-toplevel 2>/dev/null)
    if test -n "$root"
        cd $root
    else
        echo "error: not in a git repository" >&2
        return 1
    end

end
25 changes: 25 additions & 0 deletions dot_config/fish/functions/fpr.fish
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions dot_config/fish/functions/jump.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function jump
cd (dirname $argv[1])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If jump is called with no arguments, $argv[1] is empty, causing dirname to fail and output nothing. This results in cd being executed with no arguments, which unexpectedly changes the directory to $HOME.

We should validate that an argument is provided and that the target directory exists before attempting to change directories.

    if test (count $argv) -lt 1
        echo "Usage: jump <file_or_directory>" >&2
        return 1
    end
    set -l dir (dirname $argv[1])
    if test -d "$dir"
        cd "$dir"
    else
        echo "error: no such directory: $dir" >&2
        return 1
    end

end
3 changes: 3 additions & 0 deletions dot_config/fish/functions/nonascii.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function nonascii
env LC_ALL=C grep -n '[^[:print:][:space:]]' $argv[1]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using $argv[1] limits the function to only checking the first file passed. Using $argv instead allows the function to support checking multiple files, or reading from standard input if no files are provided.

    env LC_ALL=C grep -n '[^[:print:][:space:]]' $argv

end
5 changes: 5 additions & 0 deletions dot_config/fish/functions/serve.fish
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions dot_config/fish/functions/syspip.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function syspip
env PIP_REQUIRE_VIRTUALENV= pip $argv
end

function syspip3
env PIP_REQUIRE_VIRTUALENV= pip3 $argv
end
Comment on lines +5 to +7

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In Fish, autoloaded functions are loaded by filename. Because syspip3 is defined inside syspip.fish instead of its own file, calling syspip3 in a fresh shell session will fail with Unknown command unless syspip has already been executed in that session.

To fix this, syspip3 should be removed from this file and placed in its own file named dot_config/fish/functions/syspip3.fish.

5 changes: 5 additions & 0 deletions dot_config/fish/functions/xin.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function xin
cd $argv[1]; or return
set -e argv[1]
command $argv
Comment on lines +2 to +4

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In Fish, functions run in the current shell context. Calling cd inside this function will permanently change the user's working directory, defeating the purpose of xin (which is to execute a command in a directory temporarily).

We should use pushd and popd (redirecting output to /dev/null to keep it quiet) to ensure the directory change is temporary and restored afterward. We should also validate that the required arguments are provided.

    if test (count $argv) -lt 2
        echo "Usage: xin <directory> <command> [args...]" >&2
        return 1
    end
    pushd $argv[1] >/dev/null; or return
    set -e argv[1]
    $argv
    popd >/dev/null

end