From d7eabecd6be56dd2855bb833169da00f6b8a8812 Mon Sep 17 00:00:00 2001 From: Martin Schut Date: Wed, 15 Apr 2026 21:13:07 +0200 Subject: [PATCH 1/6] Fish (and other shells) autocompletion From 64561552fc90a285dfd598ff70aa79d582dd8a46 Mon Sep 17 00:00:00 2001 From: Martin Schut Date: Sun, 19 Apr 2026 21:31:14 +0200 Subject: [PATCH 2/6] Use any POSIX-compliant shell --- install.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) mode change 100644 => 100755 install.sh diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index d7c0d0f..d7d3ace --- a/install.sh +++ b/install.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # shellcheck disable=SC2016 if [ ! -f "git-pad" ] || { [ ! -f "autocompletion.bash" ] && [ ! -f "autocompletion.zsh" ]; } ; then echo '!E: Not in git-pad directory'; @@ -7,16 +7,16 @@ fi # On Windows/Git Bash, $SHELL may be unset or a Windows path # so detect the shell via version variables instead -if [[ -n "${ZSH_VERSION:-}" ]]; then +if [ -n "${ZSH_VERSION:-}" ]; then shell_name="zsh" -elif [[ -n "${BASH_VERSION:-}" ]]; then +elif [ -n "${BASH_VERSION:-}" ]; then shell_name="bash" else shell_name="$(basename "${SHELL:-unknown}")" fi # On Windows, $HOME may be unset -if [[ -z "${HOME:-}" ]]; then +if [ -z "${HOME:-}" ]; then HOME="$(cd ~ && pwd)" fi @@ -46,4 +46,4 @@ if grep -q '## git-pad' "$rc" 2>/dev/null; then grep -C 5 '## git-pad' "$rc" else echo "$block" >> "$rc" && echo "Installed successfully. Restart your shell." -fi \ No newline at end of file +fi From c2293c7b7532a68f76a93809d58bd024d5a10b7f Mon Sep 17 00:00:00 2001 From: Martin Schut Date: Sun, 19 Apr 2026 22:16:47 +0200 Subject: [PATCH 3/6] Allow passing the shell to install for --- install.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index d7d3ace..90873a9 100755 --- a/install.sh +++ b/install.sh @@ -5,14 +5,18 @@ if [ ! -f "git-pad" ] || { [ ! -f "autocompletion.bash" ] && [ ! -f "autocomplet exit 1 fi -# On Windows/Git Bash, $SHELL may be unset or a Windows path -# so detect the shell via version variables instead -if [ -n "${ZSH_VERSION:-}" ]; then - shell_name="zsh" -elif [ -n "${BASH_VERSION:-}" ]; then - shell_name="bash" +if [ $# -eq 0 ]; then + # On Windows/Git Bash, $SHELL may be unset or a Windows path + # so detect the shell via version variables instead + if [ -n "${ZSH_VERSION:-}" ]; then + exec /usr/bin/env sh $0 zsh; + elif [ -n "${BASH_VERSION:-}" ]; then + exec /usr/bin/env sh $0 bash; + else + exec /usr/bin/env sh $0 "$(basename "${SHELL:-unknown}")"; + fi else - shell_name="$(basename "${SHELL:-unknown}")" + shell_name=$1 fi # On Windows, $HOME may be unset From 03b0e493a70307210a9e091977f078e5cbfcb504 Mon Sep 17 00:00:00 2001 From: Martin Schut Date: Sun, 19 Apr 2026 23:09:23 +0200 Subject: [PATCH 4/6] Harmonize POSIX shells into a single invocation --- install.sh | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/install.sh b/install.sh index 90873a9..db7f88a 100755 --- a/install.sh +++ b/install.sh @@ -24,30 +24,27 @@ if [ -z "${HOME:-}" ]; then HOME="$(cd ~ && pwd)" fi +# Start the validation and installation +id="## git-pad" + case "$shell_name" in - bash) - rc="$HOME/.bashrc" - block=' -## git-pad -PATH=$PATH:'"$PWD"' -export PATH -. '"$PWD"'/autocompletion.bash' - ;; - zsh) - rc="$HOME/.zshrc" + bash | zsh) + rc="$HOME/.${shell_name}rc" + block=' -## git-pad +'"$id"' PATH=$PATH:'"$PWD"' export PATH -. '"$PWD"'/autocompletion.zsh' +. '"$PWD"'/autocompletion.'"$shell_name" ;; + *) echo "Unsupported shell: $shell_name"; exit 1 ;; esac -if grep -q '## git-pad' "$rc" 2>/dev/null; then +if grep -q "$id" "$rc" 2>/dev/null; then echo '!W: Looks like it is already installed' echo '--------------------------------------' - grep -C 5 '## git-pad' "$rc" + grep -C 5 "$id" "$rc" else echo "$block" >> "$rc" && echo "Installed successfully. Restart your shell." fi From 8dee91e386b65773b9e3e6137d018ef2819db674 Mon Sep 17 00:00:00 2001 From: Martin Schut Date: Mon, 20 Apr 2026 00:11:23 +0200 Subject: [PATCH 5/6] Add fish installation --- install.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index db7f88a..c89a93d 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh # shellcheck disable=SC2016 -if [ ! -f "git-pad" ] || { [ ! -f "autocompletion.bash" ] && [ ! -f "autocompletion.zsh" ]; } ; then +if [ ! -f "git-pad" ] || { [ ! -f "autocompletion.bash" ] && [ ! -f "autocompletion.zsh" ] && [ ! -f "autocompletion.fish" ]; } ; then echo '!E: Not in git-pad directory'; exit 1 fi @@ -38,6 +38,15 @@ export PATH . '"$PWD"'/autocompletion.'"$shell_name" ;; + fish) + ln -s "$PWD/autocompletion.fish" "$HOME/.config/fish/completions/git-pad.fish" + rc="$HOME/.config/fish/config.fish" + + block=' +'"$id"' +fish_add_path '"$PWD" + ;; + *) echo "Unsupported shell: $shell_name"; exit 1 ;; esac From ed55982890a072d46efe310f719a61043d973495 Mon Sep 17 00:00:00 2001 From: Martin Schut Date: Mon, 20 Apr 2026 00:17:07 +0200 Subject: [PATCH 6/6] Fish autocompletion --- .gitignore | 1 + autocompletion.fish | 51 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 autocompletion.fish diff --git a/.gitignore b/.gitignore index 40b2e45..a3a8b61 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ gh_list_dump.sql gh_list_state.json gh_list.db .git-pad-github/ +.git-pad/ diff --git a/autocompletion.fish b/autocompletion.fish new file mode 100644 index 0000000..c981889 --- /dev/null +++ b/autocompletion.fish @@ -0,0 +1,51 @@ +function __fish_git_pad_command + set -l cmd (commandline -pxc) + test (count $cmd) -gt 1 + and contains -- $cmd[2] $argv +end + +function __fish_git_pad_needs_command + test (count (commandline -pxc)) -eq 1 +end + +function __fish_git_pad_issues + set -l pad_dir (string join "/" (dirname (git rev-parse --path-format=absolute --git-common-dir)) ".git-pad/issues") + + test -d "$pad_dir" + or return + + for f in (grep -l "status: \(open\|in-progress\)" $pad_dir/*.md) + set -l issue (string match -r -g "$pad_dir/(.*)\\.md\$" $f) + set -l desc (grep -m 1 '^title:' $f | string replace -m 1 "title: " "" | string shorten -m 35) + + printf "%s\t%s\n" $issue $desc + end +end + + +# No files expansion +complete -c git-pad --no-files + +# Simple commands +complete -c git-pad -n __fish_git_pad_needs_command -a init -x -d 'Initialize a new pad' +complete -c git-pad -n __fish_git_pad_needs_command -a status -x -d 'Show status' +complete -c git-pad -n __fish_git_pad_needs_command -a commit -x -d 'Commit changes' +complete -c git-pad -n __fish_git_pad_needs_command -a log -x -d 'Show log' +complete -c git-pad -n __fish_git_pad_needs_command -a list -x -d 'List issues' +complete -c git-pad -n __fish_git_pad_needs_command -a search -x -d 'Search issues' +complete -c git-pad -n __fish_git_pad_needs_command -a remove -x -d 'Remove an issue' +complete -c git-pad -n __fish_git_pad_needs_command -a clone -x -d 'Clone a pad' +complete -c git-pad -n __fish_git_pad_needs_command -a track -x -d 'Track an issue' +complete -c git-pad -n __fish_git_pad_needs_command -a remote -x -d 'Manage remotes' +complete -c git-pad -n __fish_git_pad_needs_command -a push -x -d 'Push changes' +complete -c git-pad -n __fish_git_pad_needs_command -a pull -x -d 'Pull changes' +complete -c git-pad -n __fish_git_pad_needs_command -a fetch -x -d 'Fetch changes' +complete -c git-pad -n __fish_git_pad_needs_command -a merge -x -d 'Merge changes' +complete -c git-pad -n __fish_git_pad_needs_command -a version -x -d 'Show version' + +# Comments with issue expansion +complete -c git-pad -n __fish_git_pad_needs_command -a edit -x -d 'Edit an issue' +complete -c git-pad -n '__fish_git_pad_command edit' -a '(__fish_git_pad_issues)' -x -d Issue + +complete -c git-pad -n __fish_git_pad_needs_command -a comment -x -d 'Add a comment' +complete -c git-pad -n __fish_git_pad_needs_command -a show -x -d 'Show an issue'