Recently Written · git

sbm

dmenu bookmarks. Instantly fuzzy search thousands of bookmarks and plumb them. LOOKING FOR SUCKLESS SOFTWARE EDITION? GO TO sbm-suckless INSTEAD

git clone https://github.com/equwal/sbm

Log | Files | Refs


bm-commit (1279 bytes)

1 #!/bin/sh
2 
3 # bm-commit [message]: commit the bookmark file, and the tag file beside it,
4 # when their directory is a git repository of its own. bm runs it after every
5 # change when it is installed. It never pushes or pulls.
6 #
7 #     cd ~/.local/share/sbm && git init
8 #     printf '%s\n' '*.usage' '*.bak*' > .gitignore
9 #
10 # A file that merely sits somewhere inside a bigger repository (your dotfiles,
11 # say) is left alone, unless SBM_GIT=1. SBM_GIT=0 turns commits off.
12 
13 DATADIR=${XDG_DATA_HOME:-$HOME/.local/share}/sbm
14 BOOKMARKS=${BOOKMARKS:-$DATADIR/bookmarks}
15 USERTAGS=${USERTAGS:-$DATADIR/usertags}
16 
17 [ "${SBM_GIT:-auto}" != 0 ] || exit 0
18 dir=$(cd "$(dirname "$BOOKMARKS")" 2>/dev/null && pwd -P) || exit 0
19 top=$(git -C "$dir" rev-parse --show-toplevel 2>/dev/null) || exit 0
20 [ "${SBM_GIT:-auto}" = 1 ] || [ "$top" = "$dir" ] || exit 0
21 
22 set -- "${1:-bm: update}" "$BOOKMARKS"
23 if [ -e "$USERTAGS" ] \
24     && [ "$(cd "$(dirname "$USERTAGS")" 2>/dev/null && pwd -P)" = "$dir" ]
25 then
26     set -- "$@" "$USERTAGS"
27 fi
28 message=$1
29 shift
30 
31 git -C "$dir" add -- "$@" 2>/dev/null || exit 0
32 git -C "$dir" diff --cached --quiet -- "$@" && exit 0
33 if ! git -C "$dir" commit -q -m "$message" -- "$@" >/dev/null 2>&1; then
34     printf 'bm-commit: git commit failed in %s\n' "$dir" >&2
35     exit 1
36 fi