Directory navigator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.adoc 3.0KB

2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. sdn
  2. ===
  3. :compact-option:
  4. 'sdn' is a simple directory navigator that you can invoke while editing shell
  5. commands. It enables you to:
  6. * take a quick peek at directory contents without running `ls`
  7. * browse the filesystem without all the mess that Midnight Commander does:
  8. there's no need to create a subshell in a new pty. The current command line
  9. can be simply forwarded if it is to be edited. What's more, it will always
  10. be obvious whether the navigator is running.
  11. The only supported platform is Linux. I wanted to try a different, simpler
  12. approach here, and the end result is very friendly to tinkering.
  13. image::sdn.png[align="center"]
  14. Building
  15. --------
  16. Build dependencies: CMake and/or make, a C++14 compiler, pkg-config +
  17. Runtime dependencies: ncursesw, libacl
  18. $ git clone https://github.com/pjanouch/sdn.git
  19. $ mkdir sdn/build
  20. $ cd sdn/build
  21. $ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug
  22. $ make
  23. To install the application, you can do either the usual:
  24. # make install
  25. Or you can try telling CMake to make a package for you. For Debian it is:
  26. $ cpack -G DEB
  27. # dpkg -i sdn-*.deb
  28. There is also a Makefile you can use to quickly build a binary to be copied
  29. into the PATH of any machine you want to have 'sdn' on.
  30. zsh
  31. ---
  32. To start using this navigator, put the following in your .zshrc:
  33. ....
  34. sdn-navigate () {
  35. # ... possibly zle-line-init
  36. eval `sdn`
  37. [ -z "$cd" ] || cd "$cd"
  38. [ -z "$insert" ] || LBUFFER="$LBUFFER$insert "
  39. zle reset-prompt
  40. # ... possibly zle-line-finish
  41. }
  42. zle -N sdn-navigate
  43. bindkey '\eo' sdn-navigate
  44. ....
  45. bash
  46. ----
  47. Here we can't reset the prompt from within a `bind -x` handler but there is
  48. an acceptable workaround:
  49. ....
  50. sdn-navigate () {
  51. SDN_L=$READLINE_LINE SDN_P=$READLINE_POINT
  52. READLINE_LINE=
  53. eval `sdn`
  54. [[ -z "$cd" ]] || cd "$cd"
  55. [[ -z "$insert" ]] || {
  56. SDN_L="${SDN_L:0:$SDN_P}$insert ${SDN_L:$SDN_P}"
  57. ((SDN_P=SDN_P+${#insert}+1))
  58. }
  59. }
  60. sdn-restore () {
  61. READLINE_LINE=$SDN_L READLINE_POINT=$SDN_P
  62. unset SDN_L SDN_P
  63. }
  64. bind -x '"\200": sdn-navigate'
  65. bind -x '"\201": sdn-restore'
  66. bind '"\eo":"\200\C-m\201"'
  67. ....
  68. Colors
  69. ------
  70. Here is an example of a '~/.config/sdn/look' file; the format is similar to
  71. that of git, only named colors aren't supported:
  72. ....
  73. cursor 231 202
  74. bar 16 255 ul
  75. cwd bold
  76. input
  77. ....
  78. Similar software
  79. ----------------
  80. * https://elvish.io/ is an entire shell with an integrated ranger-like file
  81. manager on Ctrl-N (I find this confusing and resource-demanding, preferring
  82. to keep closer to "orthodox file managers")
  83. Contributing and Support
  84. ------------------------
  85. Use https://git.janouch.name/p/sdn to report any bugs, request features,
  86. or submit pull requests. `git send-email` is tolerated. If you want to discuss
  87. the project, feel free to join me at ircs://irc.janouch.name, channel #dev.
  88. Bitcoin donations are accepted at: 12r5uEWEgcHC46xd64tt3hHt9EUvYYDHe9
  89. License
  90. -------
  91. This software is released under the terms of the 0BSD license, the text of which
  92. is included within the package along with the list of authors.