README.txt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # Zsh Navigation Tools
  2. http://imageshack.com/a/img633/7967/ps6rKR.png
  3. A tool generating a selectable curses-based list of elements that has access to
  4. current Zsh session, i.e. has broad capabilities to work together with it.
  5. That's n-list. The files n-cd, n-env, n-kill, etc. are applications of
  6. the tool. Feature highlights include incremental multi-word searching, ANSI
  7. coloring, unique mode, horizontal scroll, non-selectable elements, grepping and
  8. various integrations with Zsh.
  9. ## History Widget
  10. To have n-history as the incremental searcher bound to Ctrl-R copy znt-*
  11. files into the */site-functions dir (unless you use Oh My Zsh) and
  12. add:
  13. autoload znt-history-widget
  14. zle -N znt-history-widget
  15. bindkey "^R" znt-history-widget
  16. to .zshrc. This is done automatically when using Oh My Zsh. Two other
  17. widgets exist, znt-cd-widget and znt-kill-widget, they can be too assigned
  18. to key combinations:
  19. zle -N znt-cd-widget
  20. bindkey "^T" znt-cd-widget
  21. zle -N znt-kill-widget
  22. bindkey "^Y" znt-kill-widget
  23. ## Introduction
  24. The tools are:
  25. - n-aliases - browses aliases, relegates editing to vared
  26. - n-cd - browses dirstack and bookmarked directories, allows to enter selected directory
  27. - n-functions - browses functions, relegates editing to zed or vared
  28. - n-history - browses history, allows to edit and run commands from it
  29. - n-kill - browses processes list, allows to send signal to selected process
  30. - n-env - browses environment, relegates editing to vared
  31. - n-options - browses options, allows to toggle their state
  32. - n-panelize - loads output of given command into the list for browsing
  33. All tools support horizontal scroll with <,>, {,}, h,l or left and right
  34. cursors. Other keys are:
  35. - [,] - jump directory bookmarks in n-cd and typical signals in n-kill
  36. - Ctrl-d, Ctrl-u - half page up or down
  37. - Ctrl-p, Ctrl-n - previous and next (also done with vim's j,k)
  38. - Ctrl-l - redraw of whole display
  39. - g, G - beginning and end of the list
  40. - Ctrl-o, o - enter uniq mode (no duplicate lines)
  41. - / - start incremental search
  42. - Enter - finish incremental search, retaining filter
  43. - Esc - exit incremental search, clearing filter
  44. - Ctrl-w (in incremental search) - delete whole word
  45. - Ctrl-k (in incremental search) - delete whole line
  46. ## Programming
  47. The function n-list is used as follows:
  48. n-list {element1} [element2] ... [elementN]
  49. This is all that is needed to be done to have the features like ANSI coloring,
  50. incremental multi-word search, unique mode, horizontal scroll, non-selectable
  51. elements (grepping is done outside n-list, see the tools for how it can be
  52. done). To set up non-selectable entries add their indices into array
  53. NLIST_NONSELECTABLE_ELEMENTS:
  54. typeset -a NLIST_NONSELECTABLE_ELEMENTS
  55. NLIST_NONSELECTABLE_ELEMENTS=( 1 )
  56. Result is stored as $reply[REPLY] ($ isn't needed before REPLY because
  57. of arithmetic context inside []). The returned array might be different from
  58. input arguments as n-list can process them via incremental search or uniq
  59. mode. $REPLY is the index in that possibly processed array. If $REPLY
  60. equals -1 it means that no selection have been made (user quitted via q
  61. key).
  62. To set up entries that can be jumped to with [,] keys add their indices to
  63. NLIST_HOP_INDEXES array:
  64. typeset -a NLIST_HOP_INDEXES
  65. NLIST_HOP_INDEXES=( 1 10 )
  66. n-list can automatically colorize entries according to a Zsh pattern.
  67. Following example will colorize all numbers with blue:
  68. local NLIST_COLORING_PATTERN="[0-9]##"
  69. local NLIST_COLORING_COLOR=$'\x1b[00;34m'
  70. local NLIST_COLORING_END_COLOR=$'\x1b[0m'
  71. local NLIST_COLORING_MATCH_MULTIPLE=1
  72. n-list "This is a number 123" "This line too has a number: 456"
  73. Blue is the default color, it doesn't have to be set. See zshexpn man page
  74. for more information on Zsh patterns. Briefly, comparing to regular
  75. expressions, (#s) is ^, (#e) is $, # is *, ## is +. Alternative
  76. will work when in parenthesis, i.e. (a|b). BTW by using this method you can
  77. colorize output of the tools, via their config files (check out e.g. n-cd.conf,
  78. it uses this).