Weird output on multiline command in Kitty?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I'm running non-GUI ArchLinux on VMWare 14.0. I installed a ssh server on it (by openssh) and connected to my virtual machine by using Kitty 0.70 on Windows 10 [Version 10.0.15063].



My problem is: When I use multiline command, the output of command in Kitty is really weird.




For example:



On Kitty ssh client:



[ddk@mylinux:~]
14:23:08 $ if [[ -o interactive ]]
if> then
then> echo 'inter'
then> fi

then # not my typing
echo 'inter' # not my typing
fi)inter # not my typing
[ddk@mylinux:~]
14:23:34 $


On terminal in my virtual machine:



[ddk@mylinux:~]
14:23:54 $ if [[ -o interactive ]]
if > then
then > echo interactive
then > fi
interactive
[ddk@mylinux:~]
14:24:37 $



So how do I fix improper output on my Kitty ssh client?



P/S: I am running zsh without any preconfigure scripts like oh-my-zsh. This is my .zshrc.







share|improve this question


















  • 1




    Looks like your preexec is to blame.
    – Stéphane Chazelas
    Oct 14 '17 at 9:34














up vote
2
down vote

favorite












I'm running non-GUI ArchLinux on VMWare 14.0. I installed a ssh server on it (by openssh) and connected to my virtual machine by using Kitty 0.70 on Windows 10 [Version 10.0.15063].



My problem is: When I use multiline command, the output of command in Kitty is really weird.




For example:



On Kitty ssh client:



[ddk@mylinux:~]
14:23:08 $ if [[ -o interactive ]]
if> then
then> echo 'inter'
then> fi

then # not my typing
echo 'inter' # not my typing
fi)inter # not my typing
[ddk@mylinux:~]
14:23:34 $


On terminal in my virtual machine:



[ddk@mylinux:~]
14:23:54 $ if [[ -o interactive ]]
if > then
then > echo interactive
then > fi
interactive
[ddk@mylinux:~]
14:24:37 $



So how do I fix improper output on my Kitty ssh client?



P/S: I am running zsh without any preconfigure scripts like oh-my-zsh. This is my .zshrc.







share|improve this question


















  • 1




    Looks like your preexec is to blame.
    – Stéphane Chazelas
    Oct 14 '17 at 9:34












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I'm running non-GUI ArchLinux on VMWare 14.0. I installed a ssh server on it (by openssh) and connected to my virtual machine by using Kitty 0.70 on Windows 10 [Version 10.0.15063].



My problem is: When I use multiline command, the output of command in Kitty is really weird.




For example:



On Kitty ssh client:



[ddk@mylinux:~]
14:23:08 $ if [[ -o interactive ]]
if> then
then> echo 'inter'
then> fi

then # not my typing
echo 'inter' # not my typing
fi)inter # not my typing
[ddk@mylinux:~]
14:23:34 $


On terminal in my virtual machine:



[ddk@mylinux:~]
14:23:54 $ if [[ -o interactive ]]
if > then
then > echo interactive
then > fi
interactive
[ddk@mylinux:~]
14:24:37 $



So how do I fix improper output on my Kitty ssh client?



P/S: I am running zsh without any preconfigure scripts like oh-my-zsh. This is my .zshrc.







share|improve this question














I'm running non-GUI ArchLinux on VMWare 14.0. I installed a ssh server on it (by openssh) and connected to my virtual machine by using Kitty 0.70 on Windows 10 [Version 10.0.15063].



My problem is: When I use multiline command, the output of command in Kitty is really weird.




For example:



On Kitty ssh client:



[ddk@mylinux:~]
14:23:08 $ if [[ -o interactive ]]
if> then
then> echo 'inter'
then> fi

then # not my typing
echo 'inter' # not my typing
fi)inter # not my typing
[ddk@mylinux:~]
14:23:34 $


On terminal in my virtual machine:



[ddk@mylinux:~]
14:23:54 $ if [[ -o interactive ]]
if > then
then > echo interactive
then > fi
interactive
[ddk@mylinux:~]
14:24:37 $



So how do I fix improper output on my Kitty ssh client?



P/S: I am running zsh without any preconfigure scripts like oh-my-zsh. This is my .zshrc.









share|improve this question













share|improve this question




share|improve this question








edited Oct 14 '17 at 22:05









Gilles

508k12010041533




508k12010041533










asked Oct 14 '17 at 7:55









Mark J. Adams

252213




252213







  • 1




    Looks like your preexec is to blame.
    – Stéphane Chazelas
    Oct 14 '17 at 9:34












  • 1




    Looks like your preexec is to blame.
    – Stéphane Chazelas
    Oct 14 '17 at 9:34







1




1




Looks like your preexec is to blame.
– Stéphane Chazelas
Oct 14 '17 at 9:34




Looks like your preexec is to blame.
– Stéphane Chazelas
Oct 14 '17 at 9:34










1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










As Stéphane Chazelas remarked, the problem is in your preexec function. When you set the terminal title, you use the command without protecting its special characters. The first newline in the command terminates the escape sequence to set the title, and the other lines get printed.



You would also have a problem with backslashes and percent characters in the command, since print performs backslash expansion and you're also performing prompt percent expansion on the command.



The solution is to remove or encode control characters, and to perform backslash expansion to get control characters separately from the characters in the prompt. For example:



set_title () print -rn $'e]0;'$$:-$(%):-$1$2//[^[:print:]]/_$'a' 
precmd () set_title '[%n@%M:%~]' ''
preexec () set_title '[%n@%M:%~]' " ($1)"





share|improve this answer






















  • I think we shall use a double quote (") in precmd and preexec.
    – Mark J. Adams
    Oct 18 '17 at 2:30










  • @DDK I fixed preexec. precmd doesn't need double quotes.
    – Gilles
    Oct 18 '17 at 8:42










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f398074%2fweird-output-on-multiline-command-in-kitty%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote



accepted










As Stéphane Chazelas remarked, the problem is in your preexec function. When you set the terminal title, you use the command without protecting its special characters. The first newline in the command terminates the escape sequence to set the title, and the other lines get printed.



You would also have a problem with backslashes and percent characters in the command, since print performs backslash expansion and you're also performing prompt percent expansion on the command.



The solution is to remove or encode control characters, and to perform backslash expansion to get control characters separately from the characters in the prompt. For example:



set_title () print -rn $'e]0;'$$:-$(%):-$1$2//[^[:print:]]/_$'a' 
precmd () set_title '[%n@%M:%~]' ''
preexec () set_title '[%n@%M:%~]' " ($1)"





share|improve this answer






















  • I think we shall use a double quote (") in precmd and preexec.
    – Mark J. Adams
    Oct 18 '17 at 2:30










  • @DDK I fixed preexec. precmd doesn't need double quotes.
    – Gilles
    Oct 18 '17 at 8:42














up vote
2
down vote



accepted










As Stéphane Chazelas remarked, the problem is in your preexec function. When you set the terminal title, you use the command without protecting its special characters. The first newline in the command terminates the escape sequence to set the title, and the other lines get printed.



You would also have a problem with backslashes and percent characters in the command, since print performs backslash expansion and you're also performing prompt percent expansion on the command.



The solution is to remove or encode control characters, and to perform backslash expansion to get control characters separately from the characters in the prompt. For example:



set_title () print -rn $'e]0;'$$:-$(%):-$1$2//[^[:print:]]/_$'a' 
precmd () set_title '[%n@%M:%~]' ''
preexec () set_title '[%n@%M:%~]' " ($1)"





share|improve this answer






















  • I think we shall use a double quote (") in precmd and preexec.
    – Mark J. Adams
    Oct 18 '17 at 2:30










  • @DDK I fixed preexec. precmd doesn't need double quotes.
    – Gilles
    Oct 18 '17 at 8:42












up vote
2
down vote



accepted







up vote
2
down vote



accepted






As Stéphane Chazelas remarked, the problem is in your preexec function. When you set the terminal title, you use the command without protecting its special characters. The first newline in the command terminates the escape sequence to set the title, and the other lines get printed.



You would also have a problem with backslashes and percent characters in the command, since print performs backslash expansion and you're also performing prompt percent expansion on the command.



The solution is to remove or encode control characters, and to perform backslash expansion to get control characters separately from the characters in the prompt. For example:



set_title () print -rn $'e]0;'$$:-$(%):-$1$2//[^[:print:]]/_$'a' 
precmd () set_title '[%n@%M:%~]' ''
preexec () set_title '[%n@%M:%~]' " ($1)"





share|improve this answer














As Stéphane Chazelas remarked, the problem is in your preexec function. When you set the terminal title, you use the command without protecting its special characters. The first newline in the command terminates the escape sequence to set the title, and the other lines get printed.



You would also have a problem with backslashes and percent characters in the command, since print performs backslash expansion and you're also performing prompt percent expansion on the command.



The solution is to remove or encode control characters, and to perform backslash expansion to get control characters separately from the characters in the prompt. For example:



set_title () print -rn $'e]0;'$$:-$(%):-$1$2//[^[:print:]]/_$'a' 
precmd () set_title '[%n@%M:%~]' ''
preexec () set_title '[%n@%M:%~]' " ($1)"






share|improve this answer














share|improve this answer



share|improve this answer








edited Oct 18 '17 at 8:42

























answered Oct 14 '17 at 22:05









Gilles

508k12010041533




508k12010041533











  • I think we shall use a double quote (") in precmd and preexec.
    – Mark J. Adams
    Oct 18 '17 at 2:30










  • @DDK I fixed preexec. precmd doesn't need double quotes.
    – Gilles
    Oct 18 '17 at 8:42
















  • I think we shall use a double quote (") in precmd and preexec.
    – Mark J. Adams
    Oct 18 '17 at 2:30










  • @DDK I fixed preexec. precmd doesn't need double quotes.
    – Gilles
    Oct 18 '17 at 8:42















I think we shall use a double quote (") in precmd and preexec.
– Mark J. Adams
Oct 18 '17 at 2:30




I think we shall use a double quote (") in precmd and preexec.
– Mark J. Adams
Oct 18 '17 at 2:30












@DDK I fixed preexec. precmd doesn't need double quotes.
– Gilles
Oct 18 '17 at 8:42




@DDK I fixed preexec. precmd doesn't need double quotes.
– Gilles
Oct 18 '17 at 8:42

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f398074%2fweird-output-on-multiline-command-in-kitty%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?