mirror of
https://github.com/dylanaraps/shfm.git
synced 2026-12-05 21:58:41 +00:00
various changes
- Added ? to show keybinds - Fixed some bugs
This commit is contained in:
2 files changed
+43
-41
No files matched your search
@@ -9,7 +9,7 @@ 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
|
||||||
@@ -35,17 +35,7 @@ q - quit
|
|||||||
~ - go home
|
~ - go home
|
||||||
! - spawn shell
|
! - spawn shell
|
||||||
. - toggle hidden files
|
. - toggle hidden files
|
||||||
|
? - show help
|
||||||
Additional keybinds:
|
|
||||||
|
|
||||||
down arrow - down
|
|
||||||
up arrow - up
|
|
||||||
right arrow - open file or directory
|
|
||||||
left arrow - go up level
|
|
||||||
|
|
||||||
enter/return - open file or directory
|
|
||||||
backspace - go up level
|
|
||||||
|
|
||||||
|
|
||||||
todo
|
todo
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
|
|||||||
@@ -2,22 +2,19 @@
|
|||||||
|
|
||||||
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)
|
|
||||||
DECTCEM) printf '%s[?25%s' "$esc_c" "$2" ;; # cursor visible (vt520)
|
|
||||||
screen_alt) printf '%s[?1049%s' "$esc_c" "$2" ;; # alternate buf (xterm)
|
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +87,7 @@ cmd_run() {
|
|||||||
esc screen_alt h
|
esc screen_alt h
|
||||||
esc DECTCEM h
|
esc DECTCEM h
|
||||||
esc DECSTBM
|
esc DECSTBM
|
||||||
"$@"
|
"$@" ||:
|
||||||
esc DECSTBM 1 "$((LINES - 2))"
|
esc DECSTBM 1 "$((LINES - 2))"
|
||||||
esc screen_alt l
|
esc screen_alt l
|
||||||
esc DECTCEM l
|
esc DECTCEM l
|
||||||
@@ -220,7 +217,7 @@ line_format() {
|
|||||||
file_escape "$1"
|
file_escape "$1"
|
||||||
esc EL0
|
esc EL0
|
||||||
printf %s "$safe"
|
printf %s "$safe"
|
||||||
test -d "$1" && printf /
|
[ -d "$1" ] && printf /
|
||||||
esc SGR
|
esc SGR
|
||||||
printf '\r'
|
printf '\r'
|
||||||
}
|
}
|
||||||
@@ -270,11 +267,12 @@ 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 search=0
|
||||||
redraw "$@"
|
redraw "$@"
|
||||||
else
|
|
||||||
|
elif [ -e "$cur" ]; then
|
||||||
cmd_run "${SHFM_OPENER:="${EDITOR:=vi}"}" "$cur"
|
cmd_run "${SHFM_OPENER:="${EDITOR:=vi}"}" "$cur"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@@ -309,15 +307,8 @@ main() {
|
|||||||
|
|
||||||
.?)
|
.?)
|
||||||
case ${hidden:=1} in
|
case ${hidden:=1} in
|
||||||
1)
|
1) hidden=0; set -- .[!.]* ;;
|
||||||
hidden=0
|
*) hidden=1; set -- * ;;
|
||||||
set -- .[!.]*
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
hidden=1
|
|
||||||
set -- *
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
y=1 y2=1 cur=$1
|
y=1 y2=1 cur=$1
|
||||||
@@ -368,6 +359,27 @@ main() {
|
|||||||
cmd_run "${SHELL:=/bin/sh}"
|
cmd_run "${SHELL:=/bin/sh}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
\??)
|
||||||
|
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 search=1
|
||||||
|
redraw "$@"
|
||||||
|
status_line "($y/$#) keybinds"
|
||||||
|
;;
|
||||||
|
|
||||||
q?)
|
q?)
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in new issue
Block a user