ohmyzsh/lib/misc.zsh
Lars Schneider 9544316ef9 add -F and -X to default $LESS environment variable (#6611)
The option '-F' causes 'less' to automatically quit if the contents fit 
the screen and the option '-X' causes 'less' to not clear the screen after 
quit. I think both options are generally useful for terminal applications.

They are in particular useful for Git as it runs all output through a
pager. Git will run 'less' with '-FRX' by default if the environment 
variable $LESS is not defined [1]. Since oh-my-zsh used to set $LESS to 
'-R', Git would not override this setting. Consequently, Git would 
display even a single line of output in a pager and the user would need
to explicitly quit that pager (see mailing list discussion [2]).

Therefore, lets change the oh-my-zsh default value for $LESS to '-FRX'.
This would be useful for oh-my-zsh Git users and likely for users of
other applications that use 'less' too.

[1] 36438dc19d/Documentation/config.txt (L819-L821)
[2] https://public-inbox.org/git/2412A603-4382-4AF5-97D0-D16D5FAAFE28@eluvio.com/
2018-07-24 22:55:48 +02:00

42 lines
958 B
Bash

## Load smart urls if available
# bracketed-paste-magic is known buggy in zsh 5.1.1 (only), so skip it there; see #4434
autoload -Uz is-at-least
if [[ $ZSH_VERSION != 5.1.1 ]]; then
for d in $fpath; do
if [[ -e "$d/url-quote-magic" ]]; then
if is-at-least 5.1; then
autoload -Uz bracketed-paste-magic
zle -N bracketed-paste bracketed-paste-magic
fi
autoload -Uz url-quote-magic
zle -N self-insert url-quote-magic
break
fi
done
fi
## jobs
setopt long_list_jobs
## pager
env_default PAGER 'less'
env_default LESS '-FRX'
## super user alias
alias _='sudo'
alias please='sudo'
## more intelligent acking for ubuntu users
if which ack-grep &> /dev/null; then
alias afind='ack-grep -il'
else
alias afind='ack -il'
fi
# only define LC_CTYPE if undefined
if [[ -z "$LC_CTYPE" && -z "$LC_ALL" ]]; then
export LC_CTYPE=${LANG%%:*} # pick the first entry from LANG
fi
# recognize comments
setopt interactivecomments