From b93c4ee3774d30b757b1c68b00455a4ecd6cf236 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Tue, 27 Dec 2022 04:25:56 +0100 Subject: [PATCH] zsh:glog: Only pipe to fzf if stdout is a tty This makes it easy to use `glog` in a pipe as replacement for `git log --oneline`, for example to count the commits. --- .config/zsh/autoload/git/glog | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.config/zsh/autoload/git/glog b/.config/zsh/autoload/git/glog index de9ce30..4ff65d7 100755 --- a/.config/zsh/autoload/git/glog +++ b/.config/zsh/autoload/git/glog @@ -127,7 +127,12 @@ else ) fi -# Display the commits in the above format and pipe that into fzf. -git log "$formatshort" "$dateshort" --color=always "$@" \ -| env LESS="$LESS${LESS:+ }-+F" fzf "${fzf_args[@]}" +# Display the commits in the above format and pipe that into fzf if stdout is a +# terminal. +if [ -t 1 ]; then + git log "$formatshort" "$dateshort" --color=always "$@" \ + | env LESS="$LESS${LESS:+ }-+F" fzf "${fzf_args[@]}" +else + git log "$formatshort" "$dateshort" --color=always "$@" +fi return 0