diff --git a/README.md b/README.md index 8a7d8bd..9e1c907 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,14 @@ FORGIT_FZF_DEFAULT_OPTS=" " ``` +You can forgit gitignore pager with `FORGIT_IGNORE_PAGER`. +default option is `FORGIT_IGNORE_PAGER="bat -l gitignore --color=always"` + +``` bash +# this is a example. see bat --help +FORGIT_IGNORE_PAGER='bat -l gitignore -pp --color=always --theme="Monokai Extended Origin"' +``` + Customizing fzf options for each command individually is also supported: | Command | Option | diff --git a/forgit.plugin.fish b/forgit.plugin.fish index 735e1f3..9ea44a6 100755 --- a/forgit.plugin.fish +++ b/forgit.plugin.fish @@ -238,13 +238,17 @@ if test -z "$FORGIT_GI_TEMPLATES" set -x FORGIT_GI_TEMPLATES $FORGIT_GI_REPO_LOCAL/templates end +if test -z "FORGIT_IGNORE_PAGER" + set -x FORGIT_IGNORE_PAGER bat -l gitignore --color=always +end + function forgit::ignore if not test -d "$FORGIT_GI_REPO_LOCAL" forgit::ignore::update end # https://github.com/sharkdp/bat.git - type -q bat > /dev/null 2>&1 && set cat 'bat -l gitignore --color=always' || set cat "cat" + type -q bat > /dev/null 2>&1 && set cat $FORGIT_IGNORE_PAGER || set cat "cat" set cmd "$cat $FORGIT_GI_TEMPLATES/{2}{,.gitignore} 2>/dev/null" set opts " $FORGIT_FZF_DEFAULT_OPTS @@ -264,7 +268,7 @@ function forgit::ignore end if type -q bat > /dev/null 2>&1 - forgit::ignore::get $args | bat -l gitignore + forgit::ignore::get $args | $FORGIT_IGNORE_PAGER else forgit::ignore::get $args end diff --git a/forgit.plugin.zsh b/forgit.plugin.zsh index f959c2e..ba1873a 100755 --- a/forgit.plugin.zsh +++ b/forgit.plugin.zsh @@ -166,12 +166,13 @@ forgit::cherry::pick() { export FORGIT_GI_REPO_REMOTE=${FORGIT_GI_REPO_REMOTE:-https://github.com/dvcs/gitignore} export FORGIT_GI_REPO_LOCAL="${FORGIT_GI_REPO_LOCAL:-${XDG_CACHE_HOME:-~/}}/.forgit/gi/repos/dvcs/gitignore" export FORGIT_GI_TEMPLATES=${FORGIT_GI_TEMPLATES:-$FORGIT_GI_REPO_LOCAL/templates} +export FORGIT_IGNORE_PAGER=${FORGIT_IGNORE_PAGER:-bat -l gitignore --color=always} forgit::ignore() { [ -d "$FORGIT_GI_REPO_LOCAL" ] || forgit::ignore::update local IFS cmd args cat opts # https://github.com/sharkdp/bat.git - hash bat &>/dev/null && cat='bat -l gitignore --color=always' || cat="cat" + hash bat &>/dev/null && cat="${FORGIT_IGNORE_PAGER}" || cat="cat" cmd="$cat $FORGIT_GI_TEMPLATES/{2}{,.gitignore} 2>/dev/null" opts=" $FORGIT_FZF_DEFAULT_OPTS @@ -180,11 +181,11 @@ forgit::ignore() { " # shellcheck disable=SC2206,2207 IFS=$'\n' args=($@) && [[ $# -eq 0 ]] && args=($(forgit::ignore::list | nl -nrn -w4 -s' ' | - FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd" |awk '{print $2}')) + FZF_DEFAULT_OPTS="$opts" fzf --preview="eval $cmd" | awk '{print $2}')) [ ${#args[@]} -eq 0 ] && return 1 # shellcheck disable=SC2068 if hash bat &>/dev/null; then - forgit::ignore::get ${args[@]} | bat -l gitignore + forgit::ignore::get ${args[@]} | eval "${FORGIT_IGNORE_PAGER}" else forgit::ignore::get ${args[@]} fi