Add pos(...) action to move the cursor to the numeric position

# Put the cursor on the 10th item
  seq 100 | fzf --sync --bind 'start:pos(10)'

  # Put the cursor on the 10th to last item
  seq 100 | fzf --sync --bind 'start:pos(-10)'

Close #3069
Close #395
This commit is contained in:
Junegunn Choi committed 2022-12-27 01:08:42 +09:00
1 parent d42e708d31
commit 12af069dca
5 files changed
+41 -3

No files matched your search

+3 -1
View File
@@ -890,7 +890,7 @@ const (
func init() {
executeRegexp = regexp.MustCompile(
`(?si)[:+](execute(?:-multi|-silent)?|reload|preview|change-query|change-prompt|change-preview-window|change-preview|(?:re|un)bind)`)
`(?si)[:+](execute(?:-multi|-silent)?|reload|preview|change-query|change-prompt|change-preview-window|change-preview|(?:re|un)bind|pos)`)
splitRegexp = regexp.MustCompile("[,:]+")
actionNameRegexp = regexp.MustCompile("(?i)^[a-z-]+")
}
@@ -1197,6 +1197,8 @@ func isExecuteAction(str string) actionType {
return actChangePrompt
case "change-query":
return actChangeQuery
case "pos":
return actPosition
case "execute":
return actExecute
case "execute-silent":