-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_zshrc.tmpl
More file actions
168 lines (149 loc) · 4.86 KB
/
Copy pathdot_zshrc.tmpl
File metadata and controls
168 lines (149 loc) · 4.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="refined"
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
source $ZSH/oh-my-zsh.sh
# Case-insensitive completion
autoload -U compinit && compinit
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*' menu select
setopt COMPLETE_ALIASES
# Better history search
bindkey '^R' history-incremental-search-backward
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_FIND_NO_DUPS
# Aliases
#
# vim
alias v='nvim'
alias swap='cd ~/.local/share/nvim/swap'
# git
alias gs='git status'
alias master='git checkout master && git pull'
alias main='git checkout main && git pull'
alias gco='git checkout'
alias nb='git checkout -b'
alias yeet='git stash'
# git worktrees
alias wtl='git worktree list'
alias wtp='git worktree prune'
function wta() {
if [ $# -lt 1 ]; then
echo "Usage: wta <branch-name> [base-branch]"
echo "Creates worktree at ../<repo>-<branch-name>"
echo "Defaults to latest origin/main if no base-branch specified"
return 1
fi
local branch=$1
local base=${2:-origin/main}
local repo_root=$(git rev-parse --show-toplevel)
local repo_name=$(basename "$repo_root")
local worktree_path="../${repo_name}-${branch}"
# Fetch latest main if using default base
if [ -z "$2" ]; then
echo "Fetching latest main..."
git fetch origin main
fi
git worktree add -b "$branch" "$worktree_path" "$base"
# Copy gitignored files to the new worktree
local ignored_files=$(git -C "$repo_root" ls-files --others --ignored --exclude-standard)
if [ -n "$ignored_files" ]; then
echo "Copying gitignored files..."
echo "$ignored_files" | while IFS= read -r file; do
local src="$repo_root/$file"
local dest="$worktree_path/$file"
local dest_dir=$(dirname "$dest")
mkdir -p "$dest_dir"
cp "$src" "$dest"
done
echo "Copied gitignored files to worktree"
fi
echo "Created worktree at $worktree_path"
echo "To start: cd $worktree_path && claude"
}
function wtr() {
local force=""
if [ "$1" = "-f" ] || [ "$1" = "--force" ]; then
force="--force"
shift
fi
if [ $# -lt 1 ]; then
echo "Usage: wtr [-f|--force] <branch-name>"
return 1
fi
local branch=$1
local repo_name=$(basename $(git rev-parse --show-toplevel))
local worktree_path="../${repo_name}-${branch}"
git worktree remove $force "$worktree_path"
}
function wtc() {
if [ $# -lt 1 ]; then
echo "Usage: wtc <branch-name>"
return 1
fi
local branch=$1
local repo_name=$(basename $(git rev-parse --show-toplevel))
cd "../${repo_name}-${branch}"
}
# docker
alias dogs='docker logs -t -f'
# better zsh-ing
alias ll='ls -al'
# Formatting commands
alias jsfmt='prettier --write'
alias gofmt='gofmt -w'
alias jsonf='jq .'
alias yamlf='yq eval . -P'
#gh
alias ghgh='gh cs create -R github/github -s'
alias sshpls='ssh-add .ssh/id_ed25519'
function slop {
gh slack $1 | pbcopy
}
#go
alias gop='/usr/local/share/goproxy-init.sh --override'
# SSH with Ghostty terminfo transfer
# Usage: ssh-ghostty user@host [additional ssh args]
# Automatically transfers Ghostty's terminfo to the remote server
function ssh-ghostty() {
if [ $# -eq 0 ]; then
echo "Usage: ssh-ghostty user@host [additional ssh args]"
return 1
fi
# Check if infocmp is available
if ! command -v infocmp &> /dev/null; then
echo "Error: infocmp command not found. Please install ncurses-bin or similar package."
return 1
fi
# Check if xterm-ghostty terminfo exists locally
if ! infocmp xterm-ghostty &> /dev/null; then
echo "Warning: xterm-ghostty terminfo not found locally."
echo "This function is meant to be used from a Ghostty terminal."
echo "Falling back to regular SSH..."
command ssh "$@"
return $?
fi
# Transfer terminfo and then connect
infocmp -x xterm-ghostty | command ssh "$@" -- tic -x - && command ssh "$@"
}
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
{{ if not .codespaces -}}
export ANTHROPIC_BASE_URL={{ onepasswordRead "op://Private/CLAUDE_CODE/add more/url" }}
export ANTHROPIC_AUTH_TOKEN={{ onepasswordRead "op://Private/CLAUDE_CODE/add more/password" }}
{{ end -}}
export EDITOR="nvim"
export PATH="$PATH:$(go env GOPATH)/bin"
export PATH="$HOME/.local/bin:$PATH"
{{ if .codespaces }}
# Go exports
export GOPROXY=https://nobody:${GITHUB_TOKEN}@goproxy.githubapp.com/mod,https://proxy.golang.org/,direct
export GOPRIVATE=
export GONOPROXY=
export GONOSUMDB='github.com/github/*'
# make it not ugly
export LS_COLORS="$LS_COLORS:ow=1;34:tw=1;34:"
{{ end }}
{{ if .work }}
alias capi='cd ~/code/capi'
{{ end }}