mirror of
https://github.com/dylanaraps/shfm.git
synced 2026-11-03 13:18:34 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
696318e947 | ||
|
|
9a968b2c48 | ||
|
|
25d4f809d7 | ||
|
|
01ae386143 | ||
|
|
1bbd788ee0 | ||
|
|
7b21d545b3 | ||
|
|
ec27f90096 | ||
|
|
8920178753 | ||
|
|
b8efa71b97 | ||
|
|
e9fbd754ce | ||
|
|
6849998609 | ||
|
|
2a70030c02 | ||
|
|
8ad3756a1c | ||
|
|
2e3fc777b4 | ||
|
|
0868399d04 | ||
|
|
fa04365aa2 | ||
|
|
33ce6cce78 | ||
|
|
e55cdf00ac | ||
|
|
efd8a9a233 | ||
|
|
ab3a6932fe | ||
|
|
0bd79a5f00 | ||
|
|
0b12c5397b | ||
|
|
d1c1439fa8 | ||
|
|
b9f475ac6b | ||
|
|
9741e308d5 | ||
|
|
e5fbeb04a0 | ||
|
|
16d1bd77f7 | ||
|
|
60ce38bbcf | ||
|
|
7e1d89fdfa | ||
|
|
e2f2aa9caf | ||
|
|
73075390e7 | ||
|
|
0b73009821 | ||
|
|
86389b3dbf | ||
|
|
c285271d05 | ||
|
|
9d86a19f34 | ||
|
|
e52a161f02 | ||
|
|
c20abb5dad | ||
|
|
c820159f43 | ||
|
|
c9d6c52edf | ||
|
|
2355810262 | ||
|
|
0e0759c480 | ||
|
|
d62f4bf798 | ||
|
|
c34a9fc1ce |
No files matched your search
@@ -9,12 +9,14 @@ screenshot: https://user-images.githubusercontent.com/6799467/89270554-2b40ab00-
|
|||||||
features
|
features
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
|
|
||||||
* no dependencies other than a POSIX shell + POSIX test, printf, dd and stty ***
|
* no dependencies other than a POSIX shell + POSIX [, printf, dd and stty ***
|
||||||
* tiny
|
* tiny
|
||||||
* single file
|
* single file
|
||||||
* no compilation needed
|
* no compilation needed
|
||||||
* correctly handles files with funky names (newlines, etc)
|
* correctly handles files with funky names (newlines, etc)
|
||||||
* works with very small terminal sizes.
|
* works with very small terminal sizes.
|
||||||
|
* cd on exit
|
||||||
|
* works when run in subshell $(shfm)
|
||||||
|
|
||||||
*** see portability notes towards bottom of README.
|
*** see portability notes towards bottom of README.
|
||||||
|
|
||||||
@@ -30,21 +32,22 @@ g - go to top
|
|||||||
G - go to bottom
|
G - go to bottom
|
||||||
q - quit
|
q - quit
|
||||||
: - cd to <input>
|
: - cd to <input>
|
||||||
/ - search current directory *<input>*
|
/ - search current directory <input>*
|
||||||
- - go to last directory
|
- - go to last directory
|
||||||
~ - go home
|
~ - go home
|
||||||
! - spawn shell
|
! - spawn shell
|
||||||
. - toggle hidden files
|
. - toggle hidden files
|
||||||
|
? - show help
|
||||||
|
|
||||||
Additional keybinds:
|
Also supported:
|
||||||
|
|
||||||
down arrow - down
|
down arrow - down
|
||||||
up arrow - up
|
up arrow - up
|
||||||
right arrow - open file or directory
|
left arrow - go up level
|
||||||
left arrow - go up level
|
right arrow - open file or directory
|
||||||
|
|
||||||
enter/return - open file or directory
|
backspace - up
|
||||||
backspace - go up level
|
enter - open file or directory
|
||||||
|
|
||||||
|
|
||||||
todo
|
todo
|
||||||
@@ -60,6 +63,29 @@ ________________________________________________________________________________
|
|||||||
- [x] look into whether tput is feasible.
|
- [x] look into whether tput is feasible.
|
||||||
|
|
||||||
|
|
||||||
|
cd on exit
|
||||||
|
________________________________________________________________________________
|
||||||
|
|
||||||
|
On exit, the utility will print the path to working directory to <stdout>. To
|
||||||
|
disable this behavior, run with 'shfm >/dev/null'. Usage of this output is
|
||||||
|
rather flexible.
|
||||||
|
|
||||||
|
# cd to directory on exit
|
||||||
|
cd "$(shfm)"
|
||||||
|
|
||||||
|
# store pwd in var on exit
|
||||||
|
var=$(shfm)
|
||||||
|
|
||||||
|
# store pwd in a file on exit
|
||||||
|
shfm > file
|
||||||
|
|
||||||
|
For ease of use, a wrapper function can be added to your .shellrc (.bashrc, etc).
|
||||||
|
|
||||||
|
shfm() {
|
||||||
|
cd "$(command shfm "$@")"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
opener
|
opener
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
|
|
||||||
@@ -149,9 +175,9 @@ ________________________________________________________________________________
|
|||||||
* VT100/ANSI escape sequences (widely available) are used in place of tput. A
|
* VT100/ANSI escape sequences (widely available) are used in place of tput. A
|
||||||
few non-VT100 sequences /are/ needed however.
|
few non-VT100 sequences /are/ needed however.
|
||||||
|
|
||||||
- IL vt102 \033[L: controls upwards scroll. (required)
|
- IL vt102 \033[L: upwards scroll. (required)
|
||||||
- ? xterm \033[?1049[lh]: controls alternate screen. (optional)
|
- xterm \033[?1049[lh]: alternate screen. (optional)
|
||||||
- DECTCEM vt520 \033[?25[lh]: controls cursor visibility. (optional)
|
- DECTCEM vt520 \033[?25[lh]: cursor visibility. (optional)
|
||||||
|
|
||||||
Why avoid tput?
|
Why avoid tput?
|
||||||
|
|
||||||
@@ -229,15 +255,6 @@ ________________________________________________________________________________
|
|||||||
- If input doesn't follow this sequence, 'esc' is reset to '0'.
|
- If input doesn't follow this sequence, 'esc' is reset to '0'.
|
||||||
|
|
||||||
|
|
||||||
* There is no usage of '[' or 'test'.
|
|
||||||
|
|
||||||
Despite these being commonly provided as "shell builtins" (part of the shell),
|
|
||||||
a lot of shells still use the external utilities from the coreutils. All usage
|
|
||||||
of these has been replaced with 'case' as it is always a "shell keyword".
|
|
||||||
|
|
||||||
This is one of the approaches taken to reduce the need for anything external.
|
|
||||||
|
|
||||||
|
|
||||||
* Filename escaping works via looping over a string char by char.
|
* Filename escaping works via looping over a string char by char.
|
||||||
|
|
||||||
I didn't think this was possible in POSIX shell until I needed to do this in
|
I didn't think this was possible in POSIX shell until I needed to do this in
|
||||||
|
|||||||
@@ -2,28 +2,29 @@
|
|||||||
|
|
||||||
esc() {
|
esc() {
|
||||||
case $1 in
|
case $1 in
|
||||||
# vt100 (IL is vt102)
|
# vt100 (IL is vt102) (DECTCEM is vt520)
|
||||||
CUD) printf '%s[%sB' "$esc_c" "$2" ;; # cursor down
|
CUD) printf '%s[%sB' "$esc_c" "$2" ;; # cursor down
|
||||||
CUP) printf '%s[%s;%sH' "$esc_c" "$2" "$3" ;; # cursor home
|
CUP) printf '%s[%s;%sH' "$esc_c" "$2" "$3" ;; # cursor home
|
||||||
CUU) printf '%s[%sA' "$esc_c" "$2" ;; # cursor up
|
CUU) printf '%s[%sA' "$esc_c" "$2" ;; # cursor up
|
||||||
DECAWM) printf '%s[?7%s' "$esc_c" "$2" ;; # line wrap
|
DECAWM) printf '%s[?7%s' "$esc_c" "$2" ;; # line wrap
|
||||||
DECRC) printf '%s8' "$esc_c" ;; # cursor restore
|
DECRC) printf '%s8' "$esc_c" ;; # cursor restore
|
||||||
DECSC) printf '%s7' "$esc_c" ;; # cursor save
|
DECSC) printf '%s7' "$esc_c" ;; # cursor save
|
||||||
DECSTBM) printf '%s[%s;%sr' "$esc_c" "$2" "$3" ;; # scroll region
|
DECSTBM) printf '%s[%s;%sr' "$esc_c" "$2" "$3" ;; # scroll region
|
||||||
ED[0-2]) printf '%s[%sJ' "$esc_c" "${1#ED}" ;; # clear screen
|
DECTCEM) printf '%s[?25%s' "$esc_c" "$2" ;; # cursor visible
|
||||||
EL[0-2]) printf '%s[%sK' "$esc_c" "${1#EL}" ;; # clear line
|
ED[0-2]) printf '%s[%sJ' "$esc_c" "${1#ED}" ;; # clear screen
|
||||||
IL) printf '%s[%sL' "$esc_c" "$2" ;; # insert line
|
EL[0-2]) printf '%s[%sK' "$esc_c" "${1#EL}" ;; # clear line
|
||||||
SGR) printf '%s[%s;%sm' "$esc_c" "$2" "$3" ;; # colors
|
IL) printf '%s[%sL' "$esc_c" "$2" ;; # insert line
|
||||||
|
SGR) printf '%s[%s;%sm' "$esc_c" "$2" "$3" ;; # colors
|
||||||
|
|
||||||
# private (and optional)
|
# xterm (since 1988, supported widely)
|
||||||
DECTCEM) printf '%s[?25%s' "$esc_c" "$2" ;; # cursor visible (vt520)
|
screen_alt) printf '%s[?1049%s' "$esc_c" "$2" ;; # alternate buffer
|
||||||
screen_alt) printf '%s[?1049%s' "$esc_c" "$2" ;; # alternate buf (xterm)
|
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
term_setup() {
|
term_setup() {
|
||||||
stty=$(stty -g)
|
stty=$(stty -g)
|
||||||
stty -icanon -echo
|
stty -icanon -echo
|
||||||
|
esc screen_alt h
|
||||||
esc DECAWM l
|
esc DECAWM l
|
||||||
esc DECTCEM l
|
esc DECTCEM l
|
||||||
esc ED2
|
esc ED2
|
||||||
@@ -31,11 +32,15 @@ term_setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
term_reset() {
|
term_reset() {
|
||||||
esc DECAWM h
|
esc DECAWM h >&2
|
||||||
esc DECTCEM h
|
esc DECTCEM h >&2
|
||||||
esc ED2
|
esc ED2 >&2
|
||||||
esc DECSTBM
|
esc DECSTBM >&2
|
||||||
|
esc screen_alt l >&2
|
||||||
stty "$stty"
|
stty "$stty"
|
||||||
|
|
||||||
|
# needed for cd-on-exit
|
||||||
|
printf '%s\n' "$PWD" >&1
|
||||||
}
|
}
|
||||||
|
|
||||||
term_resize() {
|
term_resize() {
|
||||||
@@ -54,47 +59,46 @@ term_resize() {
|
|||||||
|
|
||||||
term_scroll_down() {
|
term_scroll_down() {
|
||||||
case $((y - $#)) in
|
case $((y - $#)) in
|
||||||
-*)
|
[0-9]*) return
|
||||||
y=$((y + 1))
|
|
||||||
y2=$((y2 + 1 < bottom ? y2 + 1 : bottom))
|
|
||||||
|
|
||||||
line_print "$((y - 1))" "$@"
|
|
||||||
printf '\n'
|
|
||||||
line_print "$y" "$@"
|
|
||||||
status_line "($y/$#) $PWD"
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
y=$((y + 1))
|
||||||
|
y2=$((y2 + 1 < bottom ? y2 + 1 : bottom))
|
||||||
|
|
||||||
|
line_print "$((y - 1))" "$@"
|
||||||
|
printf '\n'
|
||||||
|
line_print "$y" "$@"
|
||||||
|
status_line "$#"
|
||||||
}
|
}
|
||||||
|
|
||||||
term_scroll_up() {
|
term_scroll_up() {
|
||||||
case $y in
|
case $y in
|
||||||
-*|0|1) ;;
|
-*|0|1) return
|
||||||
|
|
||||||
*)
|
|
||||||
y=$((y - 1))
|
|
||||||
|
|
||||||
line_print "$((y + 1))" "$@"
|
|
||||||
|
|
||||||
case $y2 in
|
|
||||||
1) esc IL ;;
|
|
||||||
*) esc CUU; y2=$((y2 > 1 ? y2 - 1 : 1))
|
|
||||||
esac
|
|
||||||
|
|
||||||
line_print "$y" "$@"
|
|
||||||
status_line "($y/$#) $PWD"
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
y=$((y - 1))
|
||||||
|
|
||||||
|
line_print "$((y + 1))" "$@"
|
||||||
|
|
||||||
|
case $y2 in
|
||||||
|
1) esc IL ;;
|
||||||
|
*) esc CUU; y2=$((y2 > 1 ? y2 - 1 : 1))
|
||||||
|
esac
|
||||||
|
|
||||||
|
line_print "$y" "$@"
|
||||||
|
status_line "$#"
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_run() {
|
cmd_run() {
|
||||||
esc screen_alt h
|
stty "$stty"
|
||||||
esc DECTCEM h
|
esc DECTCEM h
|
||||||
esc DECSTBM
|
esc DECSTBM
|
||||||
"$@"
|
esc ED2
|
||||||
|
"$@" ||:
|
||||||
esc DECSTBM 1 "$((LINES - 2))"
|
esc DECSTBM 1 "$((LINES - 2))"
|
||||||
esc screen_alt l
|
|
||||||
esc DECTCEM l
|
esc DECTCEM l
|
||||||
esc CUP "$y2"
|
stty -icanon -echo
|
||||||
|
hist=2
|
||||||
}
|
}
|
||||||
|
|
||||||
file_escape() {
|
file_escape() {
|
||||||
@@ -103,9 +107,9 @@ file_escape() {
|
|||||||
# loop over string char by char
|
# loop over string char by char
|
||||||
while c=${tmp%"${tmp#?}"}; do
|
while c=${tmp%"${tmp#?}"}; do
|
||||||
case $c in
|
case $c in
|
||||||
[[:print:]]) safe=$safe$c ;;
|
|
||||||
'') return ;;
|
'') return ;;
|
||||||
*) safe=$safe\? ;;
|
[[:cntrl:]]) safe=$safe\? ;;
|
||||||
|
*) safe=$safe$c ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
tmp=${tmp#?}
|
tmp=${tmp#?}
|
||||||
@@ -117,7 +121,7 @@ hist_search() {
|
|||||||
|
|
||||||
for file do
|
for file do
|
||||||
case ${PWD%%/}/$file in
|
case ${PWD%%/}/$file in
|
||||||
"$old_pwd") y=$j y2=$((j > bottom ? mid : j)) cur=$file
|
"$old_pwd") y=$j y2=$((j >= bottom ? mid : j)) cur=$file
|
||||||
esac
|
esac
|
||||||
|
|
||||||
j=$((j + 1))
|
j=$((j + 1))
|
||||||
@@ -132,20 +136,28 @@ list_print() {
|
|||||||
end=$((bottom + 1))
|
end=$((bottom + 1))
|
||||||
mid=$((bottom / 4 < 5 ? 1 : bottom / 4))
|
mid=$((bottom / 4 < 5 ? 1 : bottom / 4))
|
||||||
|
|
||||||
|
case $# in
|
||||||
|
1) [ -e "$1" ] || [ "$1" = 'no results' ] || set -- empty
|
||||||
|
esac
|
||||||
|
|
||||||
case $hist in
|
case $hist in
|
||||||
1)
|
2) # redraw after cmd run
|
||||||
|
shift "$((y > y2 ? y - y2 : 0))"
|
||||||
|
;;
|
||||||
|
|
||||||
|
1) # redraw after go-to-parent
|
||||||
hist_search "$@"
|
hist_search "$@"
|
||||||
shift "$((y >= bottom ? y - mid : 0))"
|
shift "$((y >= bottom ? y - mid : 0))"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*) # everything else
|
||||||
shift "$((y >= bottom ? y - bottom : 0))"
|
shift "$((y >= bottom ? y - bottom : 0))"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
for file do
|
for file do
|
||||||
case $i in
|
case $i in
|
||||||
"$y2") esc SGR 34 7
|
"$y2") esc SGR 0 7
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case $((i - end)) in
|
case $((i - end)) in
|
||||||
@@ -158,20 +170,31 @@ list_print() {
|
|||||||
i=$((i + 1))
|
i=$((i + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
esc CUP "$((y > bottom ? y2 : y))"
|
esc CUP "$((y > y2 ? y2 : y))"
|
||||||
}
|
}
|
||||||
|
|
||||||
redraw() {
|
redraw() {
|
||||||
list_print "$@"
|
list_print "$@"
|
||||||
status_line "($y/$#) $PWD"
|
status_line "$#"
|
||||||
}
|
}
|
||||||
|
|
||||||
status_line() {
|
status_line() {
|
||||||
esc DECSC
|
esc DECSC
|
||||||
esc CUP "$LINES"
|
esc CUP "$LINES"
|
||||||
esc SGR 31 7
|
|
||||||
printf '%-*s' "$COLUMNS" "$1"
|
case $USER in
|
||||||
esc SGR
|
root) esc SGR 31 7 ;;
|
||||||
|
*) esc SGR 34 7 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
printf '%*s\r%s ' "$COLUMNS" "" "($y/$1)"
|
||||||
|
|
||||||
|
case $ltype in
|
||||||
|
'') printf %s "$PWD" ;;
|
||||||
|
*) printf %s "$ltype"
|
||||||
|
esac
|
||||||
|
|
||||||
|
esc SGR 0 0
|
||||||
esc DECRC
|
esc DECRC
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +222,7 @@ line_print() {
|
|||||||
offset=$1
|
offset=$1
|
||||||
|
|
||||||
case $offset in
|
case $offset in
|
||||||
"$y") esc SGR 34 7
|
"$y") esc SGR 0 7
|
||||||
esac
|
esac
|
||||||
|
|
||||||
shift "$offset"
|
shift "$offset"
|
||||||
@@ -213,10 +236,11 @@ line_print() {
|
|||||||
|
|
||||||
line_format() {
|
line_format() {
|
||||||
file_escape "$1"
|
file_escape "$1"
|
||||||
esc EL0
|
[ -d "$1" ] && esc SGR 1 31
|
||||||
printf %s "$safe"
|
printf %s "$safe"
|
||||||
test -d "$1" && printf /
|
[ -d "$1" ] && printf /
|
||||||
esc SGR
|
esc SGR 0 0
|
||||||
|
esc EL0
|
||||||
printf '\r'
|
printf '\r'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,16 +248,24 @@ main() {
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
-v)
|
-h|--help)
|
||||||
printf '%s 0.2\n' "${0##*/}"
|
printf 'shfm -[hv] <starting dir>\n'
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
-v|--version)
|
||||||
|
printf 'shfm 0.4.2\n'
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
cd -- "${1:-"$PWD"}"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
esc_c=$(printf '\033')
|
esc_c=$(printf '\033')
|
||||||
bs_char=$(printf '\177')
|
bs_char=$(printf '\177')
|
||||||
|
|
||||||
cd "${1:-"$PWD"}"
|
|
||||||
set -- *
|
set -- *
|
||||||
cur=$1
|
cur=$1
|
||||||
|
|
||||||
@@ -257,21 +289,23 @@ main() {
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
l?|C2|"$esc") # ARROW RIGHT
|
l?|C2|"$esc") # ARROW RIGHT
|
||||||
if cd "$cur" >/dev/null 2>&1; then
|
if [ -d "$cur" ] && cd -- "$cur" >/dev/null 2>&1; then
|
||||||
set -- *
|
set -- *
|
||||||
y=1 y2=1 cur=$1 search=0
|
y=1 y2=1 cur=$1 ltype=
|
||||||
redraw "$@"
|
redraw "$@"
|
||||||
else
|
|
||||||
|
elif [ -e "$cur" ]; then
|
||||||
cmd_run "${SHFM_OPENER:="${EDITOR:=vi}"}" "$cur"
|
cmd_run "${SHFM_OPENER:="${EDITOR:=vi}"}" "$cur"
|
||||||
|
redraw "$@"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
h?|D2|"$bs_char"?) # ARROW LEFT
|
h?|D2|"$bs_char"?) # ARROW LEFT
|
||||||
old_pwd=$PWD
|
old_pwd=$PWD
|
||||||
|
|
||||||
case $search in
|
case $ltype in
|
||||||
1) search=0 ;;
|
'') cd .. || continue ;;
|
||||||
*) cd .. || continue ;;
|
*) ltype= ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
set -- *
|
set -- *
|
||||||
@@ -291,20 +325,14 @@ main() {
|
|||||||
G?)
|
G?)
|
||||||
y=$#
|
y=$#
|
||||||
y2=$(($# < bottom ? $# : bottom))
|
y2=$(($# < bottom ? $# : bottom))
|
||||||
|
line_print "$y" "$@"
|
||||||
redraw "$@"
|
redraw "$@"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
.?)
|
.?)
|
||||||
case ${hidden:=1} in
|
case ${hidden:=1} in
|
||||||
1)
|
1) hidden=0; set -- .* ;;
|
||||||
hidden=0
|
0) hidden=1; set -- *
|
||||||
set -- .[!.]*
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
hidden=1
|
|
||||||
set -- *
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
y=1 y2=1 cur=$1
|
y=1 y2=1 cur=$1
|
||||||
@@ -313,7 +341,15 @@ main() {
|
|||||||
|
|
||||||
:?)
|
:?)
|
||||||
prompt "cd: " r
|
prompt "cd: " r
|
||||||
cd "${ans:="$0"}" >/dev/null 2>&1|| continue
|
|
||||||
|
# false positive, behavior intentional
|
||||||
|
# shellcheck disable=2088
|
||||||
|
case $ans in
|
||||||
|
'~') ans=$HOME ;;
|
||||||
|
'~/'*) ans=$HOME/${ans#"~/"}
|
||||||
|
esac
|
||||||
|
|
||||||
|
cd -- "${ans:="$0"}" >/dev/null 2>&1|| continue
|
||||||
set -- *
|
set -- *
|
||||||
y=1 y2=1 cur=$1
|
y=1 y2=1 cur=$1
|
||||||
redraw "$@"
|
redraw "$@"
|
||||||
@@ -321,14 +357,24 @@ main() {
|
|||||||
|
|
||||||
/?)
|
/?)
|
||||||
prompt / r
|
prompt / r
|
||||||
set -- *"$ans"*
|
|
||||||
y=1 y2=1 cur=$1 search=1
|
IFS=
|
||||||
|
# globbing intentional, word splitting is disabled.
|
||||||
|
# shellcheck disable=2086
|
||||||
|
set -- $ans*
|
||||||
|
unset IFS
|
||||||
|
|
||||||
|
case $1$# in
|
||||||
|
"$ans*1") set -- 'no results'
|
||||||
|
esac
|
||||||
|
|
||||||
|
y=1 y2=1 cur=$1 ltype="search $PWD/$ans*"
|
||||||
redraw "$@"
|
redraw "$@"
|
||||||
status_line "($y/$#) search $ans"
|
status_line "$#"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
-?)
|
-?)
|
||||||
cd "$OLDPWD" >/dev/null 2>&1|| continue
|
cd -- "$OLDPWD" >/dev/null 2>&1|| continue
|
||||||
set -- *
|
set -- *
|
||||||
y=1 y2=1 cur=$1
|
y=1 y2=1 cur=$1
|
||||||
redraw "$@"
|
redraw "$@"
|
||||||
@@ -345,12 +391,32 @@ main() {
|
|||||||
export SHFM_LEVEL
|
export SHFM_LEVEL
|
||||||
SHFM_LEVEL=$((SHFM_LEVEL + 1))
|
SHFM_LEVEL=$((SHFM_LEVEL + 1))
|
||||||
cmd_run "${SHELL:=/bin/sh}"
|
cmd_run "${SHELL:=/bin/sh}"
|
||||||
|
redraw "$@"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
q?)
|
\??)
|
||||||
exit 0
|
set -- 'j - down' \
|
||||||
|
'k - up' \
|
||||||
|
'l - open file or directory' \
|
||||||
|
'h - go up level' \
|
||||||
|
'g - go to top' \
|
||||||
|
'G - go to bottom' \
|
||||||
|
'q - quit' \
|
||||||
|
': - cd to <input>' \
|
||||||
|
'/ - search current directory <input>*' \
|
||||||
|
'- - go to last directory' \
|
||||||
|
'~ - go home' \
|
||||||
|
'! - spawn shell' \
|
||||||
|
'. - toggle hidden files' \
|
||||||
|
'? - show keybinds'
|
||||||
|
|
||||||
|
y=1 y2=1 cur=$1 ltype=keybinds
|
||||||
|
redraw "$@"
|
||||||
|
status_line "$#"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
q?) exit 0 ;;
|
||||||
|
|
||||||
# handle keys which emit escape sequences
|
# handle keys which emit escape sequences
|
||||||
"$esc_c"*) esc=1 ;;
|
"$esc_c"*) esc=1 ;;
|
||||||
'[1') esc=2 ;;
|
'[1') esc=2 ;;
|
||||||
@@ -359,4 +425,4 @@ main() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@" >/dev/tty
|
||||||
Reference in new issue
Block a user