diff --git a/README.md b/README.md index 2392a41..ceb924a 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 5ccebd1..91f4f70 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 \" " @@ -163,10 +164,7 @@ _forgit_add() { untracked=$(git config --get-color color.status.untracked red) # NOTE: paths listed by 'git status -su' mixed with quoted and unquoted style # remove indicators | remove original path for rename case | remove surrounding quotes - extract=" - sed 's/^.*] //' | - sed 's/.* -> //' | - sed -e 's/^\\\"//' -e 's/\\\"\$//'" + extract="sed 's/^.*] //' | sed 's/.* -> //' | sed -e 's/^\\\"//' -e 's/\\\"\$//'" preview=" file=\$(echo {} | $extract) if (git status -s -- \\\"\$file\\\" | grep '^??') &>/dev/null; then # diff with /dev/null for untracked files @@ -178,6 +176,7 @@ _forgit_add() { $FORGIT_FZF_DEFAULT_OPTS -0 -m --nth 2..,.. --preview=\"$preview\" + --bind=\"alt-e:execute-silent($EDITOR \$\(echo {} | $extract\) >/dev/tty