diff --git a/README.md b/README.md index b19833d..1522a74 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,8 @@ For linux users `FORGIT_COPY_CMD` should be set to make copy work. Example: `FOR ### ⚙ Options +#### aliases + You can change the default aliases by defining these variables below. (To disable all aliases, Set the `FORGIT_NO_ALIASES` flag.) @@ -134,6 +136,8 @@ forgit_rebase=grb forgit_checkout_branch=gcb ``` +#### pagers + Forgit will use the default configured pager from git (`core.pager`, `pager.show`, `pager.diff`) but can be altered with the following environment variables: @@ -144,6 +148,9 @@ variables: | pager on `git show` | `FORGIT_SHOW_PAGER` | `git config pager.show` _or_ `$FORGIT_PAGER` | | pager on `git diff` | `FORGIT_DIFF_PAGER` | `git config pager.diff` _or_ `$FORGIT_PAGER` | | pager on `gitignore` | `FORGIT_IGNORE_PAGER` | `bat -l gitignore --color always` _or_ `cat` | +| git log format | `FORGIT_GLO_FORMAT` | `%C(auto)%h%d %s %C(black)%C(bold)%cr%reset` | + +#### fzf options You can add default fzf options for `forgit`, including keybinds, layout, etc. (No need to repeat the options already defined in `FZF_DEFAULT_OPTS`) @@ -179,7 +186,7 @@ Complete loading order of fzf options is: 2. `FORGIT_FZF_DEFAULT_OPTS` (forgit global) 3. `FORGIT_CMD_FZF_OPTS` (command specific) -**Example** +Examples: - `ctrl-d` to drop the selected stash but do not quit fzf (`gss` specific). ``` @@ -194,6 +201,11 @@ FORGIT_LOG_FZF_OPTS=' --bind="ctrl-e:execute(echo {} |grep -Eo [a-f0-9]+ |head -1 |xargs git show |vim -)" ' ``` +#### other options + +| Option | Description | Default | +|---------------------|----------------|----------------------------------------------| +| `FORGIT_LOG_FORMAT` | git log format | `%C(auto)%h%d %s %C(black)%C(bold)%cr%reset` | ### 📦 Optional dependencies diff --git a/forgit.plugin.zsh b/forgit.plugin.zsh index a48b267..e41096a 100755 --- a/forgit.plugin.zsh +++ b/forgit.plugin.zsh @@ -12,6 +12,8 @@ forgit_show_pager=${FORGIT_SHOW_PAGER:-$(git config pager.show || echo "$forgit_ forgit_diff_pager=${FORGIT_DIFF_PAGER:-$(git config pager.diff || echo "$forgit_pager")} forgit_ignore_pager=${FORGIT_IGNORE_PAGER:-$(hash bat &>/dev/null && echo 'bat -l gitignore --color=always' || echo 'cat')} +forgit_log_format=${FORGIT_LOG_FORMAT:-%C(auto)%h%d %s %C(black)%C(bold)%cr%reset} + # git commit viewer forgit::log() { forgit::inside_work_tree || return 1 @@ -27,7 +29,7 @@ forgit::log() { " graph=--graph [[ $FORGIT_LOG_GRAPH_ENABLE == false ]] && graph= - eval "git log $graph --color=always --format='%C(auto)%h%d %s %C(black)%C(bold)%cr%Creset' $* $forgit_emojify" | + eval "git log $graph --color=always --format='$forgit_log_format' $* $forgit_emojify" | FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd" } @@ -168,7 +170,7 @@ forgit::rebase() { local cmd preview opts graph files commit graph=--graph [[ $FORGIT_LOG_GRAPH_ENABLE == false ]] && graph= - cmd="git log $graph --color=always --format='%C(auto)%h%d %s %C(black)%C(bold)%cr%Creset' $* $forgit_emojify" + cmd="git log $graph --color=always --format='$forgit_log_format' $* $forgit_emojify" files=$(sed -nE 's/.* -- (.*)/\1/p' <<< "$*") # extract files parameters for `git show` command preview="echo {} |grep -Eo '[a-f0-9]+' |head -1 |xargs -I% git show --color=always % -- $files | $forgit_show_pager" opts=" @@ -187,7 +189,7 @@ forgit::checkout::branch() { [[ $# -ne 0 ]] && { git checkout -b "$*"; return $?; } local cmd preview opts cmd="git branch --color=always --verbose --all --format=\"%(if:equals=HEAD)%(refname:strip=3)%(then)%(else)%(refname:short)%(end)\" $forgit_emojify | sed '/^$/d'" - preview="git log {} --graph --pretty=format:'%C(auto)%h%d %s %C(black)%C(bold)%cr%Creset' --color=always --abbrev-commit --date=relative" + preview="git log {} --graph --pretty=format:'$forgit_log_format' --color=always --abbrev-commit --date=relative" opts=" $FORGIT_FZF_DEFAULT_OPTS +s +m --tiebreak=index --ansi