Skip to content

Commit c0e978e

Browse files
committed
Merge branch 'document-cli-commands'
* Branch commit log: doc/jj-fzf.1.md: describe how to run key binding commands via the CLI doc/jj-fzf.1.md: describe command-line options to jj-fzf jj-fzf: allow bookmark/push/rebase/reparent/oplog/evolog as CLI commands lib/setup.sh: jjfzf_run: support +x to skip command display README.md: add star history chart to README Signed-off-by: Tim Janik <timj@gnu.org>
2 parents 854e998 + f228f46 commit c0e978e

File tree

4 files changed

+57
-23
lines changed

4 files changed

+57
-23
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ This application is licensed under
137137
[MPL-2.0](https://github.com/tim-janik/jj-fzf/blob/master/LICENSE).
138138

139139

140+
## Star History
141+
142+
[![Star History Chart](https://api.star-history.com/svg?repos=tim-janik/jj-fzf&type=Timeline)](https://star-history.com/#tim-janik/jj-fzf)
143+
140144
<!-- MARKDOWN LINKS & IMAGES -->
141145
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
142146
[irc-badge]: https://img.shields.io/badge/Live%20Chat-Libera%20IRC-blueviolet?style=for-the-badge

doc/jj-fzf.1.md

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,31 @@
44
jj-fzf - Terminal interface for the `jj` version control system based on fzf
55

66
# SYNOPSIS
7-
**jj-fzf** [*COMMAND*] [*ARGUMENTS*...]
7+
**jj-fzf** [*OPTIONS*] \
8+
**jj-fzf** *COMMAND* [*ARGUMENTS*...]
9+
10+
# OPTIONS
11+
12+
**--version**
13+
: Print version information.
14+
15+
**--help**
16+
: Print brief usage information.
17+
18+
**--man**
19+
: Browse this man page.
20+
21+
**--no-preview**
22+
: Hide the preview window.
23+
24+
**-c**, **+c**
25+
: Start as a commit picker, **-c** picks a single commit, **+c** picks multiple commits.
26+
27+
**-r**, **+r**
28+
: Start as a revision (change ID) picker, **-r** picks a single revision, **+r** picks multiple revisions.
29+
30+
**-s**
31+
: Start as a revset picker, returns the edited / current revset expression.
832

933
# DESCRIPTION
1034

@@ -16,8 +40,8 @@
1640
separate view for the operations log, `jj op log`, allows fast previews of
1741
diffs and commit histories of past operations and enabling undo of previous
1842
actions. The available hotkeys are displayed on-screen for easy
19-
discoverability. The commands and key bindings can also be displayed with
20-
`jj-fzf --help` and are documented in the **jj-fzf** wiki.
43+
discoverability. The commands and key bindings can also be found in the man
44+
page (displayed with `jj-fzf --man`) and are documented in the **jj-fzf** wiki.
2145

2246
## JJ LOG VIEW
2347

@@ -93,10 +117,12 @@
93117

94118
For all repository-modifying commands, **jj-fzf** prints the actual `jj` commands
95119
executed to stderr. The output aids users in learning how to use `jj` directly
96-
to achieve the desired effects. It can also be useful when debugging and helps
97-
users determine which actions they might wish to undo. Most commands can also
98-
be run via the command line, using: \
99-
`jj-fzf <command> <revision>`
120+
to achieve the desired effects. This output can also be useful when debugging and
121+
helps users determine which actions they might wish to undo.
122+
123+
Most commands can also be run directly from the command line. The supported
124+
commands are the same as the key bindings listed below (e.g., `abandon`,
125+
`squash`, etc.). The arguments are typically one or more commit or change IDs.
100126

101127
# KEY BINDINGS
102128

jj-fzf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ DOC[commit]='Use `jj commit` to describe the currently selected revision and cre
7878
# Delete bookmarks & tags
7979
KEY[bookmark]="Alt-B"
8080
DOC[bookmark]='Create, move, delete jj bookmarks and git tags.'
81-
BINDINGS+=( --bind "alt-b:execute( '$JJFZF_ABSPATHLIB'/bookmarks.sh -m {2} ; jjfzf_load_and_status )+$RELOAD" )
81+
RUN[bookmark]="jjfzf_run +x +e '$JJFZF_ABSPATHLIB'/bookmarks.sh -m {2}"
8282

8383
# Diffedit interactively
8484
KEY[diffedit]="Alt-E"
@@ -151,8 +151,8 @@ DOC[absorb]='Use `jj absorb` to split the content diff of the current revision a
151151

152152
# Reparent Commits
153153
KEY[reparent]="Alt-P"
154-
BINDINGS+=( --bind "alt-p:execute( '$JJFZF_ABSPATHLIB'/reparent.sh {+2} ; jjfzf_load_and_status )+$RELOAD" )
155154
DOC[reparent]='Change parent(s) of the current revision by adding a new or removing an existing parent, and optionally simplify the parent list.'
155+
RUN[reparent]="jjfzf_run +x +e '$JJFZF_ABSPATHLIB'/reparent.sh {+2}"
156156

157157
# Squash
158158
KEY[squash]="Alt-Q"
@@ -210,8 +210,8 @@ export -f jjfzf_restore
210210

211211
# Rebase Commits
212212
KEY[rebase]="Alt-R"
213-
BINDINGS+=( --bind "alt-r:execute( '$JJFZF_ABSPATHLIB'/rebase.sh {+2} ; jjfzf_load_and_status )+$RELOAD" )
214213
DOC[rebase]='Use `jj rebase` or `jj duplicate` to move or copy a set of revisions (possibly with descendants), onto, before or after another revision. Also supports `jj simplify-parents` afterwards.'
214+
RUN[rebase]="jjfzf_run +x +e '$JJFZF_ABSPATHLIB'/rebase.sh {+2}"
215215

216216
# Revert Commits
217217
KEY[revert]="Alt-V" POST[revert]="+first"
@@ -314,12 +314,13 @@ DOC[new]='Use `jj new` to create a new revision on top of the currently selected
314314

315315
# Oplog Commits
316316
KEY[oplog]="Ctrl-O"
317-
BINDINGS+=( --bind "ctrl-o:execute( '$JJFZF_ABSPATHLIB'/oplog.sh ; jjfzf_load_and_status )+$RELOAD" )
317+
RUN[oplog]="jjfzf_run +x +e '$JJFZF_ABSPATHLIB'/oplog.sh"
318318
DOC[oplog]='Use `jj operation log` to browse the recent operations log. Use hotkeys to view operation diffs and history. Undo operations or restore its working copy into a new commit.'
319319

320320
# Push & fetch from remotes
321321
KEY[push]="Ctrl-P" POST[new]="+first"
322322
DOC[push]='Use `jj git fetch` and `jj git push --tracked --deleted` to update the local and remote repositories. Pushing needs confirmation after a dry-run. Tries to push all refs if no revisions are currently selected.'
323+
RUN[push]="jjfzf_push {2} {+2}"
323324
jjfzf_push()
324325
(
325326
set -Eeuo pipefail
@@ -347,23 +348,22 @@ jjfzf_push()
347348
jjfzf_load_and_status
348349
)
349350
export -f jjfzf_push
350-
BINDINGS+=( --bind "ctrl-p:execute( jjfzf_push {2} {+2} )+$RELOAD" )
351351

352352
# Evolog Commits
353353
KEY[evolog]="Ctrl-V"
354-
BINDINGS+=( --bind "ctrl-v:execute( '$JJFZF_ABSPATHLIB'/evolog.sh {2} ; jjfzf_load_and_status )+$RELOAD" )
355354
DOC[evolog]='Use `jj evolog` to browse the evolution of the selected revision. Inject historic commits into the ancestry without changing descendants.'
355+
RUN[evolog]="jjfzf_run +x +e '$JJFZF_ABSPATHLIB'/evolog.sh {2}"
356356

357357
# Subshell
358358
KEY[shell]="Ctrl-Z"
359-
BINDINGS+=( --bind "ctrl-z:execute( jjfzf_exec_usershell )+execute( jjfzf_load_and_status )+$RELOAD+refresh-preview" )
360359
DOC[shell]='Start interactive subshell.'
360+
BINDINGS+=( --bind "ctrl-z:execute( jjfzf_exec_usershell )+execute( jjfzf_load_and_status )+$RELOAD+refresh-preview" )
361361
# This needs to run execute() twice, because of the exec in jjfzf_exec_usershell
362362

363363
# Reload
364364
KEY[reload]="F5"
365-
BINDINGS+=( --bind "f5:execute( jjfzf_load_and_status )+$RELOAD+refresh-preview" )
366365
DOC[reload]='Reload the revset.'
366+
BINDINGS+=( --bind "f5:execute( jjfzf_load_and_status )+$RELOAD+refresh-preview" )
367367

368368
# Interactive Revset
369369
BINDINGS+=( --bind 'change:reload: jjfzf_revset_log {q} ' )
@@ -430,7 +430,7 @@ export -f jjfzf_set_revset
430430
if [ -v "RUN[${1-}]" ]; then
431431
KEY="$1" && CMD="${RUN[$KEY]}" ; shift
432432
if [[ "$CMD" =~ \{ ]] ; then
433-
CIDS=( $(jjfzf_list_change_ids "$@") )
433+
CIDS=( $(jjfzf_list_change_ids "${@-@}") )
434434
test "${#CIDS[@]}" -lt 1 &&
435435
die "missing revisions for command: $KEY"
436436
# Placeholder replacments

lib/setup.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,10 @@ export -f jjfzf_load_and_status
214214
jjfzf_run()
215215
(
216216
set -Eeuo pipefail
217-
IGNORE=false NOLOAD=false
217+
IGNORE=false NOLOAD=false _X=-x
218218
while test $# -ne 0 ; do
219219
case "$1" in \
220+
+x) _X=+x ;;
220221
+e) IGNORE=true ;;
221222
+n) NOLOAD=true ;;
222223
+*) true ;; # skip
@@ -226,13 +227,16 @@ jjfzf_run()
226227
done
227228
ERR=0
228229
if test -n "${1-}" ; then
229-
( set -x; "$@" ) || {
230+
if ( set $_X; "$@" ) ; then
231+
:
232+
else
230233
ERR=$?
231-
echo "jj-fzf: command exit_status=$ERR" >&2
232-
$IGNORE ||
233-
read -t 1 || :
234-
$IGNORE && ERR=0
235-
}
234+
$IGNORE &&
235+
ERR=0 || {
236+
echo "jj-fzf: command exit_status=$ERR" >&2
237+
read -t 1 || : # pause
238+
}
239+
fi
236240
fi
237241
$NOLOAD || jjfzf_load_and_status
238242
exit $ERR

0 commit comments

Comments
 (0)