If I started git diff, and my changes were less than one page, the command will automatically exit. This is undesirable because it is in a script, and I call immediately git commit. This skips the change lists on one page.
git diff
git commit
My first thought would be to convey the differences in less, but this does not mean that change changes do not display a blank screen (which requires a click q). Here is the command I use: git diff --color=always | less.
less
q
git diff --color=always | less
Is there a better way to do this?
bash script :
#!/bin/bash num_lines=$(git diff | wc -l) if [ $num_lines -eq 0 ] then echo "No changes" else git diff --color=always | less --raw-control-chars fi
, @Phillip comment, @tripleee:
git diff --color=always | (IFS=$'\n' read -r A; if [ -n "$A" ]; then (printf '%s\n' "$A"; cat) | less --raw-control-chars; else echo "No changes"; fi)
git diff .
@tripiple:
read -r, . . IFS=$'\n' read -r. echo , ( echo ) - printf '%s\n' "$A", .
read -r
IFS=$'\n'
echo
printf '%s\n' "$A"
--raw-control-chars ( -r), less, .
--raw-control-chars
-r
, , less -F git. less , less. , git FRX less. ( less, git less -FRX.)
-F
git
FRX
less -FRX
- .gitconfig :
.gitconfig
[core] pager = less -+F
less , less
LESS=FRX less -+F
, -F , less, .
( , less . , , LESS=X , -F .)
LESS=X
less ,
export LESS=-E
. , -E ,
-E
LESS=-E"${LESS#-}"
git, , -
alias git='LESS=-E"${LESS#-}" git'
( sh, Bash, ksh, zsh ..)
sh
ksh
zsh
, . , .
Source: https://habr.com/ru/post/1654489/More articles:How to create CRUD with gRPC service without much repetition? - protocol-buffersRegex is a matching string that: and - regexAzure Service Fabric and scheduled tasks - scheduled-tasksΠΠΈΠ½Π°ΠΌΠΈΡΠ΅ΡΠΊΠΈΠΉ ΠΈΠ½Π΄Π΅ΠΊΡ FosElasticaBundle? - phpΠΠ°ΠΊΠ°Ρ Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½Π°Ρ ΡΠ΅Π»Ρ ΠΌΠΎΠΆΠ΅Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ai_protocol Π² ΠΏΠΎΠ΄ΡΠΊΠ°Π·ΠΊΠ°Ρ ΠΏΡΠΈ Π²ΡΠ·ΠΎΠ²Π΅ ΠΌΠ΅ΡΠΎΠ΄Π° getaddrinfo(), ΠΊΠΎΠ³Π΄Π° ΡΠΆΠ΅ ΡΠΊΠ°Π·Π°Π½ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡ ai_socktype? - chow to change 2D Eigen :: Tensor to Eigen :: Matrix - tensorflowLoss and accuracy of validation in LSTM networks with Keras - deep-learningGoogle Forms Script application: how to check if the current transmission corrects a response or a new response - google-apps-scriptPHP Firebase help - configuring JWT - phpjQuery simultaneous addClass and removeClass - javascriptAll Articles