Git Product home page Git Product logo

Comments (4)

sunaku avatar sunaku commented on May 20, 2024

The cursor is always 😈 moved to the end on line 251:

  # the search was succesful so display the result properly by clearing away
  # existing highlights and moving the cursor to the end of the result buffer
  if [[ $_history_substring_search_refresh_display -eq 1 ]]; then
    region_highlight=()
    CURSOR=${#BUFFER}  # <== HERE \o/ line 251
  fi

Try commenting out that line; it might do exactly what you're dreaming of. β›…

from zsh-history-substring-search.

 avatar commented on May 20, 2024

hey @aktau
i have been digging about and found the answer this at the book 'From Bash to Z Shell', page 360-361, which google books removes partially (at least from my view), section Case Study 4: Chaining Widgets Together.
that was yesterday. today i found another thread and zle built-ins which does almost exactly what you want. check Gilles 2 answers, which more or less do what bash history-preserve-point does..
https://unix.stackexchange.com/questions/16101/zsh-search-history-on-up-and-down-keys
cheers!

from zsh-history-substring-search.

koenlek avatar koenlek commented on May 20, 2024

+1 for this request. I haven't found a way to solve it yet.

from zsh-history-substring-search.

elig0n avatar elig0n commented on May 20, 2024

@aktau and everyone else interested:

In zsh, to remember the cursor position for each history entry and recall it 
each time you recall a history entry, you'd add to your ~/.zshrc:

typeset -A cursor_history
save-cursor()    cursor_history[$HISTNO]=$CURSOR
restore-cursor() CURSOR=${cursor_history[$HISTNO]-$CURSOR}

autoload -Uz add-zle-hook-widget
add-zle-hook-widget line-finish      save-cursor
add-zle-hook-widget history-line-set restore-cursor

(note that that history is not preserved between shell invocations, only within 
the current shell session).

It also doesn't save the current cursor position when you leave the currently 
edited line. For that, you'd also need to wrap at least all history motion 
widgets so they do a save-cursor first:

for w (${(Mk)widgets:#.*hist*}) {
  functions[${w#.}]='save-cursor; zle '$w
  zle -N ${w#?}
}

Source: StΓ©phane Chazelas @ https://unix.stackexchange.com/a/630708/283551

from zsh-history-substring-search.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.