Compare commits
2 Commits
c892680974
...
93108710e4
| Author | SHA1 | Date | |
|---|---|---|---|
| 93108710e4 | |||
| 6faed4df92 |
2
.local/bin/git-cln
Executable file
2
.local/bin/git-cln
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
sh ~/.local/bin/git-worktree-setup.sh "$@"
|
||||||
21
.local/bin/git-worktree-setup.sh
Normal file
21
.local/bin/git-worktree-setup.sh
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
url=$1
|
||||||
|
basename=${url##*/}
|
||||||
|
name=${2:-${basename%.*}}
|
||||||
|
|
||||||
|
mkdir -p "$name"
|
||||||
|
cd "$name"
|
||||||
|
|
||||||
|
git clone --bare "$url" .bare
|
||||||
|
echo "gitdir: ./.bare" > .git
|
||||||
|
|
||||||
|
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
||||||
|
git fetch origin
|
||||||
|
|
||||||
|
default_branch=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
|
||||||
|
git worktree add "$default_branch"
|
||||||
|
|
||||||
|
osascript -e "tell application \"Terminal\" to do script \"cd '$PWD/$default_branch' && clear\" in front window"
|
||||||
30
.zshrc
30
.zshrc
@ -133,6 +133,36 @@ alias rm=trash
|
|||||||
|
|
||||||
alias gst="git status"
|
alias gst="git status"
|
||||||
alias gwt="git worktree"
|
alias gwt="git worktree"
|
||||||
|
|
||||||
|
do_cd_worktree() {
|
||||||
|
# Must be in a git repo
|
||||||
|
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||||
|
echo "Not in a git repository"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get worktree root (handles being in subdirectory of worktree)
|
||||||
|
local wt_root=$(git rev-parse --show-toplevel 2>/dev/null)
|
||||||
|
local project_root=$(dirname "$wt_root")
|
||||||
|
|
||||||
|
# If we're in the bare repo root, project_root is parent
|
||||||
|
if [[ -d "$wt_root/.bare" ]]; then
|
||||||
|
project_root="$wt_root"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get worktree directories (exclude bare repo)
|
||||||
|
local selected=$(git worktree list --porcelain | \
|
||||||
|
grep '^worktree ' | \
|
||||||
|
cut -d' ' -f2- | \
|
||||||
|
grep -v '\.bare$' | \
|
||||||
|
xargs -I{} basename {} | \
|
||||||
|
fzf --height 10% --color=light,hl:196,hl+:196)
|
||||||
|
|
||||||
|
if [[ -n "$selected" ]]; then
|
||||||
|
cd "${project_root}/${selected}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
alias wt="do_cd_worktree"
|
||||||
alias gdf="gdifftool"
|
alias gdf="gdifftool"
|
||||||
alias fuck="init_thefuck"
|
alias fuck="init_thefuck"
|
||||||
alias nvm="fnm"
|
alias nvm="fnm"
|
||||||
|
|||||||
@ -8,7 +8,8 @@
|
|||||||
"editor.fontWeight": "normal",
|
"editor.fontWeight": "normal",
|
||||||
"window.titleBarStyle": "native",
|
"window.titleBarStyle": "native",
|
||||||
"window.commandCenter": false,
|
"window.commandCenter": false,
|
||||||
"window.nativeTabs": true,
|
"window.nativeTabs": false,
|
||||||
|
"workbench.editor.showTabs": "single",
|
||||||
"workbench.editor.showIcons": false,
|
"workbench.editor.showIcons": false,
|
||||||
"workbench.layoutControl.enabled": false,
|
"workbench.layoutControl.enabled": false,
|
||||||
"workbench.colorTheme": "MacOS Modern Light - Ventura Xcode Default",
|
"workbench.colorTheme": "MacOS Modern Light - Ventura Xcode Default",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user