Как настроить zsh с помощью oh-my-zsh, чтобы история git оставалась видимой после нажатия «q»?

481
Dominik Roszkowski

Я использую zsh с oh-my-zsh каждый день, но есть кое-что, что беспокоит меня. Если я использую git logили любую другую подобную команду, то вывод занимает полное окно терминала. После нажатия qвывод очищается, и я возвращаюсь к моей подсказке.

Я хотел бы, чтобы вывод оставался на экране. Что я могу настроить, чтобы добиться этого?

Картинка стоит тысячи слов, так что вот рисунок текущего поведения:

enter image description here

А вот и мой .zshrc:

plugins=( gitfast docker osx web-search cp ) ZSH_THEME="powerlevel9k/powerlevel9k" 
0

2 ответа на вопрос

3
rhabbachi

По умолчанию и в зависимости от вашего ~/.gitconfigфайла Git будет использовать пейджер по умолчанию для вывода git logи git diffт. Д.

Чтобы отключить это поведение, вы можете использовать --no-pagerопцию:

git --no-pager log

Спасибо, это ** действительно полезно **, но на самом деле оно отображает всю историю сразу, а не решение, предоставленное @ junior-citizen Dominik Roszkowski 5 лет назад 2
2
Junior Citizen

Посмотрите, что вы настроили в core.pager. Возможно, вы установили его lessбез установленного -Xфлага. Установив этот флаг, вы не сможете lessочистить экран при выходе.

Если это так, перейдите к разделу ~/.gitconfigи отредактируйте pagerего [core]. У меня есть мой набор для -FRSX.

$ git config --get core.pager less -FRSX 

И для вашего удобства это со lessстраницы руководства, описывающей значение каждого из этих флагов:

 -F or --quit-if-one-screen Causes less to automatically exit if the entire file can be displayed on the first screen.  -R or --RAW-CONTROL-CHARS Like -r, but only ANSI "color" escape sequences are output in "raw" form. Unlike -r, the screen appearance is maintained correctly in most cases. ANSI "color" escape sequences are sequences of the form:  ESC [ ... m  where the "..." is zero or more color specification characters For the purpose of keeping track of screen appearance, ANSI color escape sequences are assumed to not move the cursor. You can make less think that characters other than "m" can end ANSI color escape sequences by setting the environment variable LESSANSIENDCHARS to the list of characters which can end a color escape sequence. And you can make less think that characters other than the standard ones may appear between the ESC and the m by setting the environment variable LESSANSIMIDCHARS to the list of characters which can appear.  -S or --chop-long-lines Causes lines longer than the screen width to be chopped (truncated) rather than wrapped. That is, the portion of a long line that does not fit in the screen width is not shown. The default is to wrap long lines; that is, display the remainder on the next line.  -X or --no-init Disables sending the termcap initialization and deinitialization strings to the terminal. This is sometimes desirable if the deinitialization string does something unnecessary, like clearing the screen.