hstr
hstr copied to clipboard
Windows WSL with zsh seems to be broken
Thanks so much for this tool!
I installed hstr
from source using the WSL instructions.
Perhaps this is a known issue but I'm using zsh
in a Windows WSL environment, ~/.zshrc
is setup based on output from hh -z
.
When hitting CTRL+R, I get the history list but when selecting a required line and hitting Enter, I just get the prompt back with the "echo" of the command I selected, however it is not executed.
$ hh
ls -l
$
Sorry, if this is a known/unsupported.
Thanks! Please let me reproduce this issue (I use Windows occasionally and did WSL port just to learn more about it).
@dvorka just wondering if you had a chance to take a look? 😄
@dannyk81 I'm on holidays for some time (and don't have Windows machine w/ me) - I will fix this one once I'm back (hopefully in 2 weeks).
Long answer: Recently I determined that Microsoft fixed (added missing implementation) of the console syscall that is used by HSTR on Linux systems (up until now there is used an ugly workaround on Windows WSL). In other words, hopefully I can remove workaround and Windows specific conditional code compilation to return back code that is used on other platforms... which should be simple and make it stable.
@dannyk81 Please check #236 and associated commit - I made it work on bash @ WSL with the workaround mentioned above. There was just wrongly used hh
in the .bashrc
hstr_winwsl
function instead of hstr
.
To make it work also in zsh @ WSL hstr_winwsl
function must be rewritten and conditional compilation used on WSL (#if defined(__MS_WSL__)
) i.e. I will have to rewrite the code below for zsh:
"function hstr_winwsl {"
" offset=${READLINE_POINT}"
" READLINE_POINT=0"
" { READLINE_LINE=$(</dev/tty hstr ${READLINE_LINE:0:offset} 2>&1 1>&$hstrout); } {hstrout}>&1"
" READLINE_POINT=${#READLINE_LINE}"
"}"
"if [[ $- =~ .*i.* ]]; then bind -x '\"\\C-r\": \"hstr_winwsl\"'; fi"
Resources:
- http://zsh.sourceforge.net/Guide/zshguide.html
... it's clear that I will need help of a skilled zsh user.
Thanks @dvorka, will give it a try and report back.
@dvorka I tried this workaround, but either I did it wrong or it doesn't solve this specific issue.
I changed the bindkey
:
- bindkey -s "\C-r" "\eqhh\n" # bind hh to Ctrl-r (for Vi mode check doc)
+ bindkey -s "\C-r" "\eqhstr\n" # bind hh to Ctrl-r (for Vi mode check doc)
$ bindkey|grep hstr
"^R" "^[qhstr^J"
But same thing happens, the selected command is simply echoed but not executed.
<hit CTRL+R and select `ls -l` command>
$ hstr
ls -l
$
@dvorka ok... I clearly misread your comment on this (hstr @ zsh @ WSL)... sorry for the noise.