tangled
alpha
login
or
join now
davidgasquez.com
/
dotfiles
1
fork
atom
๐ง Where my dotfiles lives in harmony and peace, most of the time
1
fork
atom
overview
issues
pulls
pipelines
๐ฅ Remove ai-gcm wrapper script
davidgasquez.com
3 months ago
0e3190c1
0d54b0fc
+1
-85
2 changed files
expand all
collapse all
unified
split
scripts
ai-gcm
terminal
zshrc
-84
scripts/ai-gcm
···
1
1
-
#!/usr/bin/env bash
2
2
-
set -euo pipefail
3
3
-
4
4
-
script_path="$(realpath -- "${BASH_SOURCE[0]}")"
5
5
-
dotfiles_dir="$(cd -- "$(dirname -- "${script_path}")/.." && pwd)"
6
6
-
prompt_file="${dotfiles_dir}/codex/prompts/commit.md"
7
7
-
8
8
-
worker() {
9
9
-
local session=$1
10
10
-
local prompt_file=$2
11
11
-
local repo_root=$3
12
12
-
13
13
-
local head_before
14
14
-
head_before="$(git rev-parse HEAD 2>/dev/null || true)"
15
15
-
16
16
-
local codex_status
17
17
-
if codex -a never exec -C "${repo_root}" - < "${prompt_file}"; then
18
18
-
codex_status=0
19
19
-
else
20
20
-
codex_status=$?
21
21
-
fi
22
22
-
23
23
-
local head_after
24
24
-
head_after="$(git rev-parse HEAD 2>/dev/null || true)"
25
25
-
26
26
-
echo
27
27
-
printf "Repo: %s\n" "${repo_root}"
28
28
-
printf "Codex exit: %s\n" "${codex_status}"
29
29
-
echo
30
30
-
31
31
-
local new_commits=0
32
32
-
local notify_body="Codex finished. No new commits."
33
33
-
if [[ -n ${head_before} && -n ${head_after} && ${head_before} != "${head_after}" ]]; then
34
34
-
new_commits=1
35
35
-
notify_body="Commits ready. Review & push?"
36
36
-
37
37
-
echo "New commits:"
38
38
-
git --no-pager log --oneline --decorate "${head_before}..${head_after}"
39
39
-
echo
40
40
-
fi
41
41
-
42
42
-
if command -v notify-send >/dev/null 2>&1; then
43
43
-
notify-send "aigcm" "${notify_body}" || true
44
44
-
fi
45
45
-
46
46
-
if command -v uwsm >/dev/null 2>&1; then
47
47
-
uwsm app -- alacritty --hold --working-directory "${repo_root}" --command tmux attach -t "${session}" >/dev/null 2>&1 &
48
48
-
else
49
49
-
alacritty --hold --working-directory "${repo_root}" --command tmux attach -t "${session}" >/dev/null 2>&1 &
50
50
-
fi
51
51
-
52
52
-
if ((new_commits)); then
53
53
-
local confirm
54
54
-
read -r -p "Commit messages OK? Press Enter to push (anything else to skip): " confirm
55
55
-
if [[ -z ${confirm} ]]; then
56
56
-
git push
57
57
-
else
58
58
-
echo "Skipping push."
59
59
-
fi
60
60
-
else
61
61
-
echo "No new commits created."
62
62
-
fi
63
63
-
64
64
-
echo
65
65
-
read -r -p "Press Enter to close... " _
66
66
-
}
67
67
-
68
68
-
main() {
69
69
-
if [[ ${1:-} == "--worker" ]]; then
70
70
-
shift
71
71
-
worker "$@"
72
72
-
return 0
73
73
-
fi
74
74
-
75
75
-
local repo_root
76
76
-
repo_root="$(git rev-parse --show-toplevel)"
77
77
-
78
78
-
local session
79
79
-
session="aigcm-$(date +%s)"
80
80
-
tmux new-session -d -s "${session}" -c "${repo_root}" "${script_path}" --worker "${session}" "${prompt_file}" "${repo_root}"
81
81
-
printf "Started %s (tmux). You will be prompted to push when Codex finishes.\n" "${session}"
82
82
-
}
83
83
-
84
84
-
main "$@"
+1
-1
terminal/zshrc
···
66
66
67
67
# Functions
68
68
aigcm() {
69
69
-
ai-gcm "$@"
69
69
+
tmux new-session -d -s "aigcm-$(date +%s)" "codex exec - < $HOME/projects/dotfiles/codex/prompts/commit.md"
70
70
}
71
71
72
72
qgs() {