Skip to content

Commit 8753600

Browse files
committed
chore: updates
1 parent 262666e commit 8753600

8 files changed

Lines changed: 114 additions & 58 deletions

File tree

dot_local/bin/executable_cleanup-branches.sh

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,61 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

3-
# Fetch all branches and prune remote-tracking branches that no longer exist
4-
git fetch --all --prune
3+
set -euo pipefail
4+
5+
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
6+
echo "Not inside a git repository."
7+
exit 1
8+
fi
9+
10+
base_branch="$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')"
11+
if [[ -z "$base_branch" ]]; then
12+
if git show-ref --verify --quiet refs/heads/main; then
13+
base_branch="main"
14+
elif git show-ref --verify --quiet refs/heads/master; then
15+
base_branch="master"
16+
else
17+
echo "Could not determine default base branch (origin/HEAD, main, or master)."
18+
exit 1
19+
fi
20+
fi
521

6-
# Store the current branch
7-
original_branch=$(git branch --show-current)
22+
current_branch="$(git branch --show-current)"
823

9-
# Get a list of all local branches, excluding 'main' and branches that start with '_'
10-
branches=$(git branch --format="%(refname:short)" | grep -v '^main$' | grep -v '^_')
24+
echo "Using base branch: $base_branch"
25+
git fetch --all --prune
1126

12-
if [ -z "$branches" ]; then
13-
echo "No branches found for cleanup."
27+
branches="$({
28+
git branch --format='%(refname:short)' \
29+
| grep -v "^${base_branch}$" \
30+
| grep -v '^_' \
31+
| grep -v "^${current_branch}$"
32+
} || true)"
33+
34+
if [[ -z "$branches" ]]; then
35+
echo "No local branches found for cleanup."
1436
exit 0
1537
fi
1638

17-
# Iterate over each branch and check if it contains any commits not in 'main'
1839
for branch in $branches; do
19-
# Check if branch has any unique commits compared to 'main'
20-
unique_commits=$(git rev-list --count $branch ^main)
40+
unique_commits="$(git rev-list --count "$branch" "^${base_branch}")"
2141

22-
if [ "$unique_commits" -eq 0 ]; then
23-
# No unique commits, offer to delete
24-
echo "Branch '$branch' is fully included in 'main' and can be deleted."
25-
read -p "Do you want to delete branch '$branch'? (y/n): " choice
26-
if [ "$choice" = "y" ]; then
27-
git branch -d "$branch"
42+
if [[ "$unique_commits" -eq 0 ]]; then
43+
echo "Branch '$branch' is fully included in '$base_branch' and can be deleted."
44+
read -r -p "Delete branch '$branch'? (y/n): " choice
45+
if [[ "$choice" == "y" ]]; then
46+
git branch --delete "$branch"
2847
echo "Deleted branch '$branch'."
2948
else
3049
echo "Skipped branch '$branch'."
3150
fi
3251
else
33-
# Unique commits exist, show the diff as if 'main' was merged into the branch
34-
echo "Branch '$branch' has $unique_commits unique commit(s) not in 'main'."
35-
echo "Showing the diff between 'main' and '$branch' as if 'main' was merged into '$branch':"
36-
37-
# Switch to the branch
38-
git checkout "$branch" > /dev/null 2>&1
39-
40-
# Perform a merge without committing, to simulate the merge
41-
git merge --no-commit --no-ff main
42-
43-
# Show the colored diff for the merge result
44-
git diff main --color
45-
46-
# Abort the merge to return to the original branch state
47-
git merge --abort
48-
49-
# Switch back to the original branch
50-
git checkout "$original_branch" > /dev/null 2>&1
51-
52-
# Offer to delete the branch after showing the diff
53-
read -p "Do you want to delete branch '$branch' despite unique commits? (y/n): " choice
52+
echo "Branch '$branch' has $unique_commits unique commit(s) not in '$base_branch'."
53+
echo "Showing diff for '${base_branch}...${branch}':"
54+
git --no-pager diff --color=always "${base_branch}...${branch}" || true
5455

55-
if [ "$choice" = "y" ]; then
56-
git branch -D "$branch"
56+
read -r -p "Delete branch '$branch' despite unique commits? (y/n): " choice
57+
if [[ "$choice" == "y" ]]; then
58+
git branch --delete --force "$branch"
5759
echo "Deleted branch '$branch'."
5860
else
5961
echo "Skipped branch '$branch'."

dot_local/bin/executable_oc-nvim

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
#!/usr/bin/env bash
2-
export ANTHROPIC_API_KEY=$(op read --account createxyz.1password.com --no-newline "op://Employee/Anthropic API Key/credential")
2+
3+
set -euo pipefail
4+
5+
op_account="${OP_ACCOUNT:-createxyz.1password.com}"
6+
anthropic_ref="${ANTHROPIC_OP_REF:-op://Employee/Anthropic API Key/credential}"
7+
8+
anthropic_api_key="$(op read --account "$op_account" --no-newline "$anthropic_ref")"
9+
if [[ -z "$anthropic_api_key" ]]; then
10+
echo "Failed to read Anthropic API key from 1Password reference: $anthropic_ref"
11+
exit 1
12+
fi
13+
14+
export ANTHROPIC_API_KEY="$anthropic_api_key"
315
exec opencode "$@"

dot_local/bin/executable_opencode-server.fish

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
11
#!/usr/bin/env fish
22

3-
# Ensure manual 1Password session exists (or prompt once when needed)
4-
set -gx OP_ACCOUNT createxyz.1password.com
3+
if not command -q op
4+
echo "Missing required command: op"
5+
exit 1
6+
end
7+
8+
if not command -q opencode
9+
echo "Missing required command: opencode"
10+
exit 1
11+
end
12+
13+
if not set -q OP_ACCOUNT
14+
set -gx OP_ACCOUNT createxyz.1password.com
15+
end
16+
517
op whoami --account $OP_ACCOUNT >/dev/null 2>&1
618

7-
set -l anthropic_key (op read --account $OP_ACCOUNT --no-newline "op://Employee/Anthropic API Key/credential")
8-
test -n "$anthropic_key"; or exit 1
19+
set -l anthropic_ref "op://Employee/Anthropic API Key/credential"
20+
set -l openai_ref "op://Employee/OpenAI API Key/credential"
21+
22+
set -l anthropic_key (op read --account $OP_ACCOUNT --no-newline "$anthropic_ref")
23+
if test -z "$anthropic_key"
24+
echo "Failed to read Anthropic API key from $anthropic_ref"
25+
exit 1
26+
end
927

10-
set -l openai_key (op read --account $OP_ACCOUNT --no-newline "op://Employee/OpenAI API Key/credential")
11-
test -n "$openai_key"; or exit 1
28+
set -l openai_key (op read --account $OP_ACCOUNT --no-newline "$openai_ref")
29+
if test -z "$openai_key"
30+
echo "Failed to read OpenAI API key from $openai_ref"
31+
exit 1
32+
end
1233

1334
set -lx ANTHROPIC_API_KEY $anthropic_key
1435
set -lx OPENAI_API_KEY $openai_key

private_dot_config/fish/config.fish

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ set --global --export EDITOR nvim
22
fish_add_path ~/.local/bin
33
fish_add_path ~/.local/share/gem/ruby/3.3.0/bin
44
fish_add_path ~/.npm-global/bin
5-
set --global --export NODE_OPTIONS "--experimental-sqlite"
5+
if set -q CODER_AGENT_TOKEN
6+
set --erase NODE_OPTIONS
7+
else
8+
set --global --export NODE_OPTIONS "--experimental-sqlite"
9+
end
610

711
# Initialize zoxide (smart cd)
812
zoxide init fish | source
@@ -43,11 +47,10 @@ direnv hook fish | source
4347
set --global --export SSH_AUTH_SOCK $XDG_RUNTIME_DIR/ssh-agent.socket
4448
set --global --export GPG_TTY (tty)
4549

46-
# Auto set using nvmrc
47-
function __nvm_auto --on-variable PWD
48-
nvm use --silent 2>/dev/null
50+
# Initialize fnm and auto-switch versions from .nvmrc/.node-version
51+
if command -q fnm
52+
fnm env --use-on-cd --shell fish | source
4953
end
50-
__nvm_auto
5154

5255
if status --is-interactive
5356
set --global fish_key_bindings fish_default_key_bindings
@@ -81,7 +84,15 @@ if status --is-interactive
8184
set --global fish_pager_color_progress brwhite --background=cyan
8285
set --global fish_pager_color_selected_background -r
8386

84-
powerline-daemon -q
85-
set --global fish_function_path $fish_function_path "/usr/lib/python3.14/site-packages/powerline/bindings/fish"
86-
powerline-setup
87+
if command -q powerline-daemon
88+
powerline-daemon -q
89+
end
90+
91+
if test -d "/usr/lib/python3.14/site-packages/powerline/bindings/fish"
92+
set --global fish_function_path $fish_function_path "/usr/lib/python3.14/site-packages/powerline/bindings/fish"
93+
end
94+
95+
if command -q powerline-setup
96+
powerline-setup
97+
end
8798
end
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
jorgebucaran/nvm.fish
21
franciscolourenco/done
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
vim.g.copilot_node_command = "~/.nvm/versions/node/v14.15.5/bin/node"
1+
vim.g.copilot_node_command = "node"
22
vim.g.copilot_no_tab_map = true
33
vim.g.copilot_assume_mapped = true
44
vim.g.copilot_tab_fallback = ""

run_once_install-packages.sh.tmpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ sudo pacman -S --needed --noconfirm \
2121
neovim \
2222
ripgrep \
2323
tmux \
24+
unzip \
2425
zoxide
2526

2627
{{ else if eq .chezmoi.osRelease.id "ubuntu" -}}
@@ -69,6 +70,7 @@ retry_apt sudo apt-get install -y -qq \
6970
man-db \
7071
ripgrep \
7172
tmux \
73+
unzip \
7274
zoxide
7375

7476
# bat is installed as batcat on Ubuntu - symlink it
@@ -88,6 +90,14 @@ if ! command -v nvim >/dev/null 2>&1; then
8890
fi
8991

9092
{{ end -}}
93+
94+
# Install fnm without modifying shell startup files
95+
if ! command -v fnm >/dev/null 2>&1; then
96+
curl -fsSL https://fnm.vercel.app/install | bash -s -- --skip-shell --install-dir "$HOME/.local/share/fnm"
97+
mkdir -p "$HOME/.local/bin"
98+
ln -sf "$HOME/.local/share/fnm/fnm" "$HOME/.local/bin/fnm"
99+
fi
100+
91101
# Set fish as default shell (applies to all distros)
92102
if [ "$(getent passwd "$(whoami)" | cut -d: -f7)" != "$(which fish)" ]; then
93103
sudo chsh -s "$(which fish)" "$(whoami)"

test/verify.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ check "fzf installed" "command -v fzf"
2727
check "ripgrep installed" "command -v rg"
2828
check "tmux installed" "command -v tmux"
2929
check "zoxide installed" "command -v zoxide"
30+
check "fnm installed" "command -v fnm"
3031
check "direnv installed" "command -v direnv"
3132
check "gh (GitHub CLI) installed" "command -v gh"
3233

0 commit comments

Comments
 (0)