From c78c10a028f664893d5def1f3c8713fa3957f6d9 Mon Sep 17 00:00:00 2001 From: Wenxuan Date: Mon, 19 Jun 2023 09:26:07 +0800 Subject: [PATCH] feat: add a keybind to open current file in editor (#313) * feat: add a keybind to open current file in default editor --------- Signed-off-by: Wenxuan Zhang Co-authored-by: sandr01d <88739791+sandr01d@users.noreply.github.com> --- README.md | 29 +++++++++++++++-------------- bin/git-forgit | 2 ++ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 2392a41c..ceb924aa 100644 --- a/README.md +++ b/README.md @@ -116,20 +116,21 @@ Install `forgit` in just one click. ### ⌨ Keybinds -| Key | Action | -| :-------------------------------------------: | ------------------------- | -| Enter | Confirm | -| Tab | Toggle mark and move down | -| Shift - Tab | Toggle mark and move up | -| ? | Toggle preview window | -| Alt - W | Toggle preview wrap | -| Ctrl - S | Toggle sort | -| Ctrl - R | Toggle selection | -| Ctrl - Y | Copy commit hash/stash ID*| -| Ctrl - K / P | Selection move up | -| Ctrl - J / N | Selection move down | -| Alt - K / P | Preview move up | -| Alt - J / N | Preview move down | +| Key | Action | +| :-------------------------------------------: | ------------------------------------------- | +| Enter | Confirm | +| Tab | Toggle mark and move down | +| Shift - Tab | Toggle mark and move up | +| ? | Toggle preview window | +| Alt - W | Toggle preview wrap | +| Ctrl - S | Toggle sort | +| Ctrl - R | Toggle selection | +| Ctrl - Y | Copy commit hash/stash ID* | +| Ctrl - K / P | Selection move up | +| Ctrl - J / N | Selection move down | +| Alt - K / P | Preview move up | +| Alt - J / N | Preview move down | +| Alt - E | 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'`. diff --git a/bin/git-forgit b/bin/git-forgit index 5ccebd18..45d323f2 100755 --- a/bin/git-forgit +++ b/bin/git-forgit @@ -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 \" " @@ -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