larkery / zsh-histdb

A slightly better history for zsh
MIT License
1.29k stars 75 forks source link

launching midnight comader (mc) floods history with garbage #138

Closed 400thecat closed 8 months ago

400thecat commented 1 year ago

this is histdb output after I have started mc, and opened some jpg file in mc:

  mc
   mc_print_command_buffer () { printf "%s\\n" "$BUFFER" >&12; }
   zle -N mc_print_command_buffer
   bindkey '^[_' mc_print_command_buffer
   mc_print_cursor_position () { echo $CURSOR >&12}
   zle -N mc_print_cursor_position
   bindkey '^[+' mc_print_cursor_position
   _mc_precmd(){ pwd>&10;kill -STOP $$ }; precmd_functions+=(_mc_precmd)

   cd "`printf '%b' '\0057tmp'`"
larkery commented 8 months ago

I don't use mc and am not going to, but I have looked it up online. It looks like it displays a little shell prompt at the bottom. I'm guessing that when you run mc it invisibly executes those commands in an interactive shell, so they get put into the history.

It looks like mc does this using a zsh feature where commands that start with whitespace don't go into the normal history. I haven't replicated this because I don't care about it, but you could easily reproduce it yourself by amending _BORING_COMMANDS in sqlite-history.zsh to contain the regex for matching whitespace at the start of a string "^ " or maybe "^ .+$".

ps. this is a really low-quality bug report, you will generally get better results by showing some effort / describing what you've already tried / what you expect to happen / why.