Skip to content

Commit

Permalink
feat: add a keybind to open current file in editor (#313)
Browse files Browse the repository at this point in the history
* feat: add a keybind to open current file in default editor

---------

Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
Co-authored-by: sandr01d <88739791+sandr01d@users.noreply.github.com>
  • Loading branch information
wfxr and sandr01d authored Jun 19, 2023
1 parent ec1bd21 commit c78c10a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,21 @@ Install `forgit` in just one click.

### ⌨ Keybinds

| Key | Action |
| :-------------------------------------------: | ------------------------- |
| <kbd>Enter</kbd> | Confirm |
| <kbd>Tab</kbd> | Toggle mark and move down |
| <kbd>Shift</kbd> - <kbd>Tab</kbd> | Toggle mark and move up |
| <kbd>?</kbd> | Toggle preview window |
| <kbd>Alt</kbd> - <kbd>W</kbd> | Toggle preview wrap |
| <kbd>Ctrl</kbd> - <kbd>S</kbd> | Toggle sort |
| <kbd>Ctrl</kbd> - <kbd>R</kbd> | Toggle selection |
| <kbd>Ctrl</kbd> - <kbd>Y</kbd> | Copy commit hash/stash ID*|
| <kbd>Ctrl</kbd> - <kbd>K</kbd> / <kbd>P</kbd> | Selection move up |
| <kbd>Ctrl</kbd> - <kbd>J</kbd> / <kbd>N</kbd> | Selection move down |
| <kbd>Alt</kbd> - <kbd>K</kbd> / <kbd>P</kbd> | Preview move up |
| <kbd>Alt</kbd> - <kbd>J</kbd> / <kbd>N</kbd> | Preview move down |
| Key | Action |
| :-------------------------------------------: | ------------------------------------------- |
| <kbd>Enter</kbd> | Confirm |
| <kbd>Tab</kbd> | Toggle mark and move down |
| <kbd>Shift</kbd> - <kbd>Tab</kbd> | Toggle mark and move up |
| <kbd>?</kbd> | Toggle preview window |
| <kbd>Alt</kbd> - <kbd>W</kbd> | Toggle preview wrap |
| <kbd>Ctrl</kbd> - <kbd>S</kbd> | Toggle sort |
| <kbd>Ctrl</kbd> - <kbd>R</kbd> | Toggle selection |
| <kbd>Ctrl</kbd> - <kbd>Y</kbd> | Copy commit hash/stash ID* |
| <kbd>Ctrl</kbd> - <kbd>K</kbd> / <kbd>P</kbd> | Selection move up |
| <kbd>Ctrl</kbd> - <kbd>J</kbd> / <kbd>N</kbd> | Selection move down |
| <kbd>Alt</kbd> - <kbd>K</kbd> / <kbd>P</kbd> | Preview move up |
| <kbd>Alt</kbd> - <kbd>J</kbd> / <kbd>N</kbd> | Preview move down |
| <kbd>Alt</kbd> - <kbd>E</kbd> | Open file in default editor (when possible) |

\* Available when the selection contains a commit hash or a stash ID.
For linux users `FORGIT_COPY_CMD` should be set to make copy work. Example: `FORGIT_COPY_CMD='xclip -selection clipboard'`.
Expand Down
2 changes: 2 additions & 0 deletions bin/git-forgit
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ _forgit_diff() {
$FORGIT_FZF_DEFAULT_OPTS
+m -0 --bind=\"enter:execute($enter_cmd | $_forgit_enter_pager)\"
--preview=\"$preview_cmd\"
--bind=\"alt-e:execute-silent($EDITOR \$\($get_files\) >/dev/tty </dev/tty)+refresh-preview\"
$FORGIT_DIFF_FZF_OPTS
--prompt=\"$commits > \"
"
Expand Down Expand Up @@ -178,6 +179,7 @@ _forgit_add() {
$FORGIT_FZF_DEFAULT_OPTS
-0 -m --nth 2..,..
--preview=\"$preview\"
--bind=\"alt-e:execute-silent($EDITOR \$\(echo {} | $extract\) >/dev/tty </dev/tty)+refresh-preview\"
$FORGIT_ADD_FZF_OPTS
"
files=$(git -c color.status=always -c status.relativePaths=true status -su |
Expand Down

0 comments on commit c78c10a

Please sign in to comment.