1 # Copy this file into /usr/share/zsh/site-functions/
2 # and add 'autoload n-panelize` to .zshrc
4 # This function somewhat reminds the panelize feature from Midnight Commander
5 # It allows browsing output of arbitrary command. Example usage:
6 # v-panelize ls /usr/local/bin
18 unset NLIST_COLORING_PATTERN
20 [ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf
21 [ -f ~/.config/znt/n-panelize.conf ] && builtin source ~/.config/znt/n-panelize.conf
26 NLIST_REMEMBER_STATE=0
29 # Check if there is proper input
30 if [ "$#" -lt 1 ]; then
31 echo "Usage: n-panelize {command} [option|argument] ... or command | n-panelize"
35 # This loop makes script faster on some Zsh's (e.g. 5.0.8)
40 # TODO: $? doesn't reach user
41 [ "$?" -eq 127 ] && return $?
43 # Check if can reattach to terminal
44 if [[ ! -c /dev/tty && ! -t 2 ]]; then
45 echo "No terminal available (no /dev/tty)"
49 # This loop makes script faster on some Zsh's (e.g. 5.0.8)
51 list=( "${(@f)"$(<&0)"}" )
54 if [[ ! -c /dev/tty ]]; then
63 if [ "$REPLY" -gt 0 ]; then
64 selected="$reply[REPLY]"
65 print -zr "# $selected"
68 # vim: set filetype=zsh: