sdn/README.adoc

136 lines
3.5 KiB
Plaintext
Raw Normal View History

2017-06-29 02:50:39 +02:00
sdn
===
:compact-option:
'sdn' is a simple directory navigator that you can invoke while editing shell
commands. It enables you to:
* take a quick peek at directory contents without running `ls`
* browse the filesystem without all the mess that Midnight Commander does:
there's no need to create a subshell in a new pty. The current command line
can be simply forwarded if it is to be edited. What's more, it will always
be obvious whether the navigator is running.
2018-11-02 15:40:56 +01:00
The only supported platform is Linux. I wanted to try a different, simpler
approach here, and the end result is very friendly to tinkering.
2017-06-29 02:50:39 +02:00
2018-11-02 21:19:41 +01:00
image::sdn.png[align="center"]
2017-06-29 02:50:39 +02:00
Building
--------
Build dependencies: CMake and/or make, a C++14 compiler, pkg-config +
2018-11-02 21:19:41 +01:00
Runtime dependencies: ncursesw, libacl
2017-06-29 02:50:39 +02:00
// Working around libasciidoc's missing support for escaping it like \++
:doubleplus: ++
2018-11-03 17:04:50 +01:00
Unfortunately most LLVM libc++ versions have a bug that crashes 'sdn' on start.
Use GNU libstdc{doubleplus} if you're affected.
2018-11-03 17:04:50 +01:00
2020-08-28 18:24:06 +02:00
$ git clone https://git.janouch.name/p/sdn.git
2017-06-29 02:50:39 +02:00
$ mkdir sdn/build
$ cd sdn/build
$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug
$ make
To install the application, you can do either the usual:
# make install
Or you can try telling CMake to make a package for you. For Debian it is:
$ cpack -G DEB
# dpkg -i sdn-*.deb
There is also a Makefile you can use to quickly build a binary to be copied
into the PATH of any machine you want to have 'sdn' on.
zsh
---
To start using this navigator, put the following in your .zshrc:
2020-08-28 18:33:08 +02:00
....
2017-06-30 22:51:52 +02:00
sdn-navigate () {
2017-06-30 22:55:18 +02:00
# ... possibly zle-line-init
eval "`sdn`"
2017-06-30 22:55:18 +02:00
[ -z "$cd" ] || cd "$cd"
[ -z "$insert" ] || LBUFFER="$LBUFFER$insert "
zle reset-prompt
# ... possibly zle-line-finish
2017-06-29 02:50:39 +02:00
}
2017-06-30 22:51:52 +02:00
zle -N sdn-navigate
bindkey '\eo' sdn-navigate
2020-08-28 18:33:08 +02:00
....
2017-06-29 02:50:39 +02:00
2017-06-30 22:51:52 +02:00
bash
----
Here we can't reset the prompt from within a `bind -x` handler but there is
an acceptable workaround:
2020-08-28 18:33:08 +02:00
....
2017-06-30 22:51:52 +02:00
sdn-navigate () {
2017-06-30 22:55:18 +02:00
SDN_L=$READLINE_LINE SDN_P=$READLINE_POINT
READLINE_LINE=
eval "`sdn`"
2017-06-30 22:55:18 +02:00
[[ -z "$cd" ]] || cd "$cd"
[[ -z "$insert" ]] || {
SDN_L="${SDN_L:0:$SDN_P}$insert ${SDN_L:$SDN_P}"
((SDN_P=SDN_P+${#insert}+1))
}
2017-06-30 22:51:52 +02:00
}
sdn-restore () {
2017-06-30 22:55:18 +02:00
READLINE_LINE=$SDN_L READLINE_POINT=$SDN_P
unset SDN_L SDN_P
2017-06-30 22:51:52 +02:00
}
bind -x '"\200": sdn-navigate'
bind -x '"\201": sdn-restore'
bind '"\eo":"\200\C-m\201"'
2020-08-28 18:33:08 +02:00
....
2017-06-29 02:50:39 +02:00
2017-06-30 21:29:10 +02:00
Colors
------
Here is an example of a '~/.config/sdn/look' file; the format is similar to
that of git, only named colors aren't supported:
2020-08-28 18:33:08 +02:00
....
2017-06-30 21:29:10 +02:00
cursor 231 202
bar 16 255 ul
cwd bold
input
2020-08-28 18:33:08 +02:00
....
2018-11-03 15:01:39 +01:00
Filename colors are taken from the `LS_COLORS` environment variable.
2018-11-03 17:04:50 +01:00
Run `dircolors` to get some defaults.
2017-06-30 21:29:10 +02:00
Bindings
--------
To obtain more vifm-like controls, you may write the following to your
'~/.config/sdn/bindings' file:
....
normal h parent
normal l choose
normal ? help
....
2018-06-30 08:21:38 +02:00
Similar software
----------------
* https://elvish.io/ is an entire shell with an integrated ranger-like file
manager on Ctrl-N (I find this confusing and resource-demanding, preferring
to keep closer to "orthodox file managers")
2017-06-29 02:50:39 +02:00
Contributing and Support
------------------------
2018-06-22 15:39:38 +02:00
Use https://git.janouch.name/p/sdn to report any bugs, request features,
or submit pull requests. `git send-email` is tolerated. If you want to discuss
the project, feel free to join me at ircs://irc.janouch.name, channel #dev.
2017-06-29 02:50:39 +02:00
2018-06-22 15:39:38 +02:00
Bitcoin donations are accepted at: 12r5uEWEgcHC46xd64tt3hHt9EUvYYDHe9
2017-06-29 02:50:39 +02:00
License
-------
This software is released under the terms of the 0BSD license, the text of which
is included within the package along with the list of authors.