0

I am using oh-my-zsh with the following history configuration:

setopt appendhistory autocd extendedglob
setopt EXTENDED_HISTORY
setopt histignoredups sharehistory

The history search Ctrl+R and arrow keys are set to the defaults, i.e:

% bindkey '^r'
"^R" history-incremental-search-backwar

However, since a while, I am facing an issue that when searching the history for commands, I get the first line of the command with double backslash at the end, but not the other lines. In fact, this only happens when the history file is updated, if the command is fresh and I search for it on the same shell that I've entered it, I will get it correctly, but if I close the shell and reopen it, and try to retrieve the command from history, I will get it like:

-> input command:

echo \
 "multi-line command"

result when using history search (bck-i-search: echo):

echo \

Does anyone know what may be causing this? The information I found here and elsewhere did not help :(

Next I add an excerpt of my history:

 4453* cd place
 4454* someCommand -d folder \\
 4455*   --opt 1 \\
 4456*   -foo1 bar1 -foo2 bar2 -aeps 0 0.01 0.01 >&! output.log &
 4457* du -sh
 4460* ls *
 4461* exit

zsh version for the two hosts which are failling: 5.0.2 and 5.0.5.

Then I added one multiline command due to syntax:

  3723  echo $ZSH_VERSION
  3724  for x in 1 2 3; do echo $x \ndone
  3725* someCommand -d folder \\

which is working fine. A multiline quotation, as in:

echo "lala
dquote> dump
dquote> dump
dquote> ok"

resulting in:

 3732  echo "lala\ndump\ndump\nok"

and which also working fine.

This is not happening on my local machine (zsh version 5.0.7), which also results in multiline commands with \n instead of double \:

15365  echo \\n multi \\n line \\n command

And also in another remote server (4.3.11):

14133  example -d  folder \\n               -pp mpp \\n               -c mcc  \\n               -x mxxz \\n               -r mrr \\n               -e 0 \\n               -o out \\n               -debug

In all machines I use the same configuration files.

2
  • This looks like zsh has trouble reading/saving the history file correctly. Could you please add an excerpt of your history file, where you have entered multi-line commands. At best some with explicit breaks via escaped newline (like in your example), some with line-breaks in quotes and some where multiline happened due to syntax (e.g. for x in 1 2 3; do echo $x ; done with Enter being pressed after/instead of ;). Also, which version of zsh are you using (echo $ZSH_VERSION). – Adaephon Jan 25 '17 at 7:31
  • Hi ~@Adaephon, thanks for your comment. I have added the information you requested :) – Werner Jan 26 '17 at 1:04
0

Maybe this is due to the issue described here? If so, the suggested fix seems to update zsh beyond version 5.0.5.

1
  • Unfortunately it's not my case, I have zsh 5.2 :( – Werner Jun 21 '17 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.