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
1 change: 1 addition & 0 deletions .github/workflows/ci-nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ jobs:
pname:
- filen-rclone
- kanata-tray
- git-wt
exclude:
- runner: macos-15-intel
pname: kanata-tray # I'm using Karabiner-Elements on macOS
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/update-local-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ jobs:
nix-update --commit --flake gemini-cli-bin
nix-update --commit --flake filen-rclone-unwrapped
nix-update --commit --flake lima
nix-update --commit --flake git-wt

- name: Count added commits
id: count-commits
Expand Down
2 changes: 1 addition & 1 deletion home-manager/bash.nix
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
if [[ -z "''${BRUSH_VERSION+this_shell_is_brush_not_the_bash}" ]]; then
# original fzf providing key-bindigns also makes some warnings in brush likely fzf-git-sh
source "${pkgs.fzf}/share/fzf/key-bindings.bash" # Don't load completions. It much made shell startup slower
source "${pkgs.fzf-git-sh}/share/fzf-git-sh/fzf-git.sh"
source "${pkgs.patched.fzf-git-sh}/share/fzf-git-sh/fzf-git.sh"
fi

# source does not load all paths. See https://stackoverflow.com/questions/1423352/source-all-files-in-a-directory-from-bash-profile
Expand Down
4 changes: 4 additions & 0 deletions home-manager/git.nix
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ in
root = "~/repos";
};

wt = {
basedir = "../{gitroot}/.worktrees";
Copy link
Owner Author

Choose a reason for hiding this comment

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

I'm not positive to use $repo/.wt for that purpose. Some tools does not consider VCS and will target them even if added .gitignore.

https://github.com/k1LoW/git-wt/issues/83

};

# `git config --get-regexp ^alias` will show current aliases
alias = {
fixup = "commit --all --amend";
Expand Down
1 change: 1 addition & 0 deletions home-manager/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
git
# gh # Don't add gh here. Only use home-manager gh module to avoid https://github.com/cli/cli/pull/5378
ghq
patched.git-wt # `git wt` via git subcommand

sequoia-sq # Alt `gpg`
sequoia-chameleon-gnupg
Expand Down
2 changes: 1 addition & 1 deletion home-manager/zsh.nix
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ in
precmd_functions+=(set_win_title)

source "${pkgs.fzf}/share/fzf/key-bindings.zsh" # Don't load completions. It much made shell startup slower
source "${pkgs.fzf-git-sh}/share/fzf-git-sh/fzf-git.sh"
source "${pkgs.patched.fzf-git-sh}/share/fzf-git-sh/fzf-git.sh"

# source only load first path. See https://stackoverflow.com/questions/14677936/source-multiple-files-in-zshrc-with-wildcard
for file in ${../dependencies/zsh}/*; do
Expand Down
31 changes: 31 additions & 0 deletions overlays/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,37 @@
};
}
);

# Don't enable shell integrations, it replaces original `git` command.
git-wt = prev.unstable.git-wt.overrideAttrs (
finalAttrs: previousAttrs: {
# 0.15.0 or later is required to enable https://github.com/k1LoW/git-wt/pull/81
version = "0.15.0";

src = prev.fetchFromGitHub {
owner = "k1LoW";
repo = "git-wt";
tag = "v${finalAttrs.version}";
hash = "sha256-A8vkwa8+RfupP9UaUuSVjkt5HtWvqR5VmSsVg2KpeMo=";
};

vendorHash = "sha256-K5geAvG+mvnKeixOyZt0C1T5ojSBFmx2K/Msol0HsSg=";
}
);

# fzf-git.sh is hard to be customed by others. So adding patches at here
# I don't need to consider the binary cache for this package.
fzf-git-sh = prev.unstable.fzf-git-sh.overrideAttrs (
finalAttrs: previousAttrs: {
# git worktree displays absolute path by design for the flexibility.
# However I have conventions for them. I would squash the longer and duplicated prefix of paths.
# This patch makes it possible to filter the worktrees by branch names.
postPatch = previousAttrs.postPatch + ''
substituteInPlace fzf-git.sh \
--replace-fail 'git worktree list | _fzf_git_fzf \' 'git worktree list | _fzf_git_fzf --with-nth=3 \'
'';
}
);
};
})
]
5 changes: 5 additions & 0 deletions pkgs/posix_shared_functions/posix_shared_functions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ getrepo() {
'@ghq@' get "$1" && cdrepo "$1"
}

# https://github.com/junegunn/fzf-git.sh/blob/8dd169c08393b4d50c2ddd270da19705a30cbbac/README.md?plain=1#L93-L95
cdwt() {
cd "$(_fzf_git_worktrees --no-multi)" || return 1
}

cdtemp() {
local word
if [ $# -lt 1 ]; then
Expand Down