Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/packaging/postinstall_macos
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
# Enable zsh completion for specs by making sure /etc/zshrc loads the
# completion functions installed under /usr/local/share/zsh/site-functions.
#
# This script is used both by the macOS .pkg installer (as its postinstall
# script) and by the local "make install" target, so the behaviour stays
# identical between the two installation paths.
#
# It is idempotent: the whole block is wrapped in sentinel markers and is only
# appended when those markers are not already present, so running it any number
# of times never produces duplicate fpath entries or duplicate compinit calls.
set -e

ZSHRC="/etc/zshrc"
MARKER="# >>> specs completion >>>"

if ! grep -qF "$MARKER" "$ZSHRC" 2>/dev/null; then
cat >> "$ZSHRC" <<'EOF'

# >>> specs completion >>>
typeset -U fpath
fpath=(/usr/local/share/zsh/site-functions $fpath)

autoload -Uz compinit
compinit
# <<< specs completion <<<
EOF
fi

exit 0
9 changes: 9 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,25 @@ jobs:
run: |
mkdir -p pkg-root/usr/local/bin
mkdir -p pkg-root/usr/local/share/man/man1
mkdir -p pkg-root/usr/local/share/zsh/site-functions
cp specs/exe/specs pkg-root/usr/local/bin/
cp specs/exe/specs-autocomplete pkg-root/usr/local/bin/
chmod 755 pkg-root/usr/local/bin/specs
chmod 755 pkg-root/usr/local/bin/specs-autocomplete
cp specs.1.gz pkg-root/usr/local/share/man/man1/
cp .github/packaging/specs-completion.zsh pkg-root/usr/local/share/zsh/site-functions/_specs

- name: Prepare pkg scripts
run: |
mkdir -p pkg-scripts
cp .github/packaging/postinstall_macos pkg-scripts/postinstall
chmod 755 pkg-scripts/postinstall

- name: Build .pkg
run: |
pkgbuild \
--root pkg-root \
--scripts pkg-scripts \
--identifier com.github.yoavnir.specs \
--version "${SPECS_VERSION#v}" \
--install-location / \
Expand Down
2 changes: 2 additions & 0 deletions specs/src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ def python_search(arg):
$(MKDIR_C) /usr/local/share/man/man1
cp specs.1.gz /usr/local/share/man/man1/
/bin/rm specs.1.gz
$(MKDIR_C) /usr/local/share/zsh/site-functions
cp ../../.github/packaging/specs-completion.zsh /usr/local/share/zsh/site-functions/_specs
/bin/bash ../../.github/packaging/postinstall_macos

install_linux: $(EXE_DIR)/specs specs.1.gz
cp $(EXE_DIR)/specs /usr/local/bin/
Expand Down
Loading