mirror of
https://github.com/dylanaraps/shfm.git
synced 2026-11-27 20:48:18 +00:00
directory history
This commit is contained in:
1 file changed
+23
-13
@@ -23,19 +23,27 @@ term_resize() {
|
|||||||
bottom=$((LINES - 2))
|
bottom=$((LINES - 2))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hist_search() {
|
||||||
|
hist=
|
||||||
|
j=1
|
||||||
|
|
||||||
|
for file do
|
||||||
|
[ "${PWD%%/}/$file" = "$old_pwd" ] && {
|
||||||
|
y=$j y2=$((j > bottom ? bottom : j))
|
||||||
|
}
|
||||||
|
|
||||||
|
j=$((j + 1))
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
list_print() {
|
list_print() {
|
||||||
printf '\033[2J\033[H'
|
printf '\033[2J\033[H'
|
||||||
|
|
||||||
i=1
|
i=1
|
||||||
j=1
|
|
||||||
end=$((bottom + 1))
|
end=$((bottom + 1))
|
||||||
|
|
||||||
for file do
|
[ "$hist" ] &&
|
||||||
[ "${PWD%%/}/$file" = "$OLDPWD" ] &&
|
hist_search "$@"
|
||||||
y=$j y2=$((j > bottom ? bottom : j))
|
|
||||||
|
|
||||||
j=$((j + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
[ "$y" -gt "$bottom" ] &&
|
[ "$y" -gt "$bottom" ] &&
|
||||||
shift "$((y - bottom))"
|
shift "$((y - bottom))"
|
||||||
@@ -54,18 +62,17 @@ list_print() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
list_reset() {
|
list_reset() {
|
||||||
y=1
|
y=1 y2=1
|
||||||
y2=1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
redraw() {
|
redraw() {
|
||||||
list_print "$@"
|
list_print "$@"
|
||||||
status_line
|
status_line "$PWD ($y/$#)"
|
||||||
}
|
}
|
||||||
|
|
||||||
status_line() {
|
status_line() {
|
||||||
printf '\0337\033[%sH\033[31;7m%-*s\033[m\0338' \
|
printf '\0337\033[%sH\033[31;7m%-*s\033[m\0338' \
|
||||||
"$LINES" "$COLUMNS" "${1:-$PWD (y:$y y2:$y2 #:$# bot:$bottom)}"
|
"$LINES" "$COLUMNS" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
print_line() {
|
print_line() {
|
||||||
@@ -113,7 +120,8 @@ main() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
print_line "$y" "$@"
|
print_line "$y" "$@"
|
||||||
status_line
|
|
||||||
|
status_line "$PWD ($y/$#)"
|
||||||
}
|
}
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -126,7 +134,7 @@ main() {
|
|||||||
printf '\n'
|
printf '\n'
|
||||||
print_line "$y" "$@"
|
print_line "$y" "$@"
|
||||||
|
|
||||||
status_line
|
status_line "$PWD ($y/$#)"
|
||||||
}
|
}
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -144,9 +152,11 @@ main() {
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
h?|D2) # ARROW LEFT
|
h?|D2) # ARROW LEFT
|
||||||
|
old_pwd=$PWD
|
||||||
cd .. || continue
|
cd .. || continue
|
||||||
set -- *
|
set -- *
|
||||||
list_reset
|
list_reset
|
||||||
|
hist=1
|
||||||
redraw "$@"
|
redraw "$@"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user