Skip to content

Commit 17121bf

Browse files
committed
git-worktree-switcher: init at 0.2.4
[`git worktree` documentation](https://git-scm.com/docs/git-worktree) [`git-worktree-switcher` repository](https://github.com/mateusauler/git-worktree-switcher) From the project's description: > Switch between git worktrees with speed. It's a wrapper script around `git worktree` making some tasks, like switching between worktrees, easier. > [!Note] > `git worktree` is a little known feature and adding QoL things can help it's adoption as it's a considerable upgrade against the `git stash` workflow.
1 parent e5bd86b commit 17121bf

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
diff --git a/wt b/wt
2+
index 60999f2..5687822 100755
3+
--- a/wt
4+
+++ b/wt
5+
@@ -27,7 +27,6 @@ help_message() {
6+
echo -e "\twt: go to the main worktree"
7+
echo -e "\twt <worktree-name>: search for worktree names and change to that directory."
8+
echo -e "\twt names: list out only the git worktree names."
9+
- echo -e "\twt update: update to the latest release of worktree switcher."
10+
echo -e "\twt version: show the CLI version."
11+
echo -e "\twt init <shell>: print the init script for <shell>."
12+
echo -e "\twt help: shows this help message."
13+
@@ -163,9 +162,6 @@ case "${args[0]}" in
14+
names)
15+
worktree_list_names
16+
;;
17+
-update)
18+
- update
19+
- ;;
20+
help)
21+
help_message
22+
;;
23+
@@ -176,7 +172,6 @@ init)
24+
init
25+
;;
26+
*)
27+
- auto_check_update
28+
directory=$(git worktree list --porcelain 2> /dev/null | sed -n '/'"${arg:-.}"'/{s/^worktree\s*//p;q}')
29+
;;
30+
esac
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
lib,
3+
stdenv,
4+
fetchFromGitHub,
5+
makeWrapper,
6+
installShellFiles,
7+
git,
8+
jq,
9+
}:
10+
11+
stdenv.mkDerivation (finalAttrs: {
12+
pname = "git-worktree-switcher";
13+
version = "0.2.4";
14+
15+
src = fetchFromGitHub {
16+
owner = "mateusauler";
17+
repo = "git-worktree-switcher";
18+
rev = "refs/tags/${finalAttrs.version}-fork";
19+
hash = "sha256-N+bDsLEUM6FWhyliUav2n5hwMa5EEuVPoIK+Cja0DxA=";
20+
};
21+
22+
buildInputs = [
23+
jq
24+
git
25+
];
26+
27+
nativeBuildInputs = [
28+
makeWrapper
29+
installShellFiles
30+
];
31+
32+
patches = [
33+
./disable-update.patch # Disable update and auto update functionality
34+
];
35+
36+
installPhase = ''
37+
mkdir -p $out/bin
38+
39+
cp wt $out/bin
40+
wrapProgram $out/bin/wt --prefix PATH : ${
41+
lib.makeBinPath [
42+
git
43+
jq
44+
]
45+
}
46+
47+
installShellCompletion --zsh completions/_wt_completion
48+
installShellCompletion --bash completions/wt_completion
49+
installShellCompletion --fish completions/wt.fish
50+
'';
51+
52+
meta = {
53+
homepage = "https://github.com/mateusauler/git-worktree-switcher";
54+
description = "Switch between git worktrees with speed.";
55+
license = lib.licenses.mit;
56+
platforms = lib.platforms.all;
57+
mainProgram = "wt";
58+
maintainers = with lib.maintainers; [ jiriks74 ];
59+
};
60+
})

0 commit comments

Comments
 (0)