Skip to content

Commit b46a9af

Browse files
committed
Hishtory: Add to package lists and fix setup script
Add hishtory to both darwin and linux package lists with eget options for its non-standard release assets (bare binaries, no archives). Rework the setup script to use install --skip-config-modification instead of init, so that config.{sh,zsh} shell integration files are created. Use a temp copy workaround for a hishtory bug where install unlinks the binary on PATH before copying os.Args[0] to it, which fails when they are the same file. Set HISHTORY_SERVER during install so the host registers with the custom sync server.
1 parent 0e1a7cd commit b46a9af

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

home/.chezmoidata/package_specs.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ softwarePackages:
117117
command: hishtory
118118
eget:
119119
source: ddworken/hishtory
120+
name: hishtory
121+
asset:
122+
- ^.intoto
123+
- ^server
124+
download_only: true
120125
vscode:
121126
cask: visual-studio-code
122127
zoxide:

home/.chezmoidata/packages.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ packages:
1919
- fzf
2020
- gh
2121
- git
22+
- hishtory
2223
- git-delta
2324
- jq
2425
- ripgrep
@@ -49,6 +50,7 @@ packages:
4950
- ripgrep
5051
- fd
5152
- gh
53+
- hishtory
5254
- tmux
5355
- vim
5456
- starship

home/.chezmoiscripts/run_once_after_040-setup-hishtory.sh.tmpl

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,30 @@ if [[ -f "${HOME}/.hishtory/config.sh" ]]; then
1515
dot::chezmoi_script_skipped "hishtory is already configured"
1616
fi
1717

18-
dot::step::start "initializing hishtory shell integration"
19-
hishtory install --skip-config-modification || dot::step::fatal
18+
dot::step::start "initializing hishtory"
19+
# We use `hishtory install --skip-config-modification` rather than `hishtory init`
20+
# because install creates ~/.hishtory/config.{sh,zsh} (the shell integration files)
21+
# while init only sets up the database and secret key.
22+
#
23+
# --skip-config-modification prevents install from mangling shell rc files, since
24+
# our dotfiles already handle sourcing the config files.
25+
#
26+
# The temp copy workaround is needed because install does the following:
27+
# 1. LookPath("hishtory") -> finds ~/.local/bin/hishtory
28+
# 2. Unlinks that path (to prepare for a fresh copy)
29+
# 3. Copies os.Args[0] to that path
30+
# When the binary IS on PATH, os.Args[0] and the LookPath result are the same
31+
# file, so step 2 deletes the binary before step 3 can copy it. Running from a
32+
# temp copy ensures the source survives the unlink.
33+
_hishtory_tmp="$(mktemp)"
34+
cp "$(command -v hishtory)" "$_hishtory_tmp"
35+
chmod +x "$_hishtory_tmp"
36+
{{ if .hishtory_server -}}
37+
HISHTORY_SERVER={{ .hishtory_server | quote }} "$_hishtory_tmp" install --skip-config-modification || dot::step::fatal
38+
{{- else -}}
39+
"$_hishtory_tmp" install --skip-config-modification --offline || dot::step::fatal
40+
{{- end }}
41+
rm -f "$_hishtory_tmp"
2042
dot::step::done
2143

2244
dot::success "hishtory configured"

0 commit comments

Comments
 (0)