added general purpose file browser with proper launcher
parent
02a4409e8a
commit
7c18316e4f
@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# getting focused pwd
|
||||||
|
PID=$(xdotool getwindowfocus getwindowpid)
|
||||||
|
child=$PID
|
||||||
|
children=()
|
||||||
|
while [ -n "$child" ] ; do
|
||||||
|
children+=($child)
|
||||||
|
child=$(pgrep -P $child)
|
||||||
|
done
|
||||||
|
|
||||||
|
last_ps=$(ps ${children[-1]} | grep -v PID | awk '{print $5}')
|
||||||
|
|
||||||
|
if [ "$last_ps" == "tmux" ] ; then
|
||||||
|
current_pane=$(tmux list-panes | grep '(active)' | grep -o '^[0-9]')
|
||||||
|
cwd=$(tmux display-message -p -t $current_pane -F '#{pane_current_path}')
|
||||||
|
else
|
||||||
|
cwd=$(readlink -e /proc/${children[-2]}/cwd)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# change to the directory
|
||||||
|
cd $cwd
|
||||||
|
files=$(find * -type f)
|
||||||
|
|
||||||
|
selection=$(echo "$files" | rofi-dmenu)
|
||||||
|
|
||||||
|
# exit on quit
|
||||||
|
if [ -z "$selection" ] ; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# grab extension
|
||||||
|
extension=$(echo "$selection" | grep -o '.\([a-zA-Z]\+\)$')
|
||||||
|
|
||||||
|
# get proper opener
|
||||||
|
case "$extension" in
|
||||||
|
'.pdf') prg="zathura" ;;
|
||||||
|
'.md') prg="vim" ;;
|
||||||
|
'.png') prg="feh" ;;
|
||||||
|
'.jpg') prg="feh" ;;
|
||||||
|
'.jpeg') prg="feh" ;;
|
||||||
|
*) prg="xdg-open" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [[ "$1" == '-S' && "$prg" =~ [feh|zathura] ]] ; then
|
||||||
|
swallow $prg "$selection"
|
||||||
|
else
|
||||||
|
$prg "$selection"
|
||||||
|
fi
|
@ -1 +1 @@
|
|||||||
Subproject commit bbb6d4891009de7dab05ad8fc2d39f272d7a751c
|
Subproject commit 94e3b0990017a42fa4581ea3d0bc08b897727d4d
|
@ -1 +1 @@
|
|||||||
Subproject commit a3f17d3baf70df58b9d3544ea30abe52a7a832c2
|
Subproject commit 942fe5faef47b21241e970551eba407bc10d9547
|
@ -1 +1 @@
|
|||||||
Subproject commit 23cc4bca2f586c8c2f7d2cb78bbbfec4b7361763
|
Subproject commit a494378f6c106a97e39c62b493c14476f9f7de4f
|
@ -1 +1 @@
|
|||||||
Subproject commit fea8bee382b2051b0137fd2cacf0862823ee69b3
|
Subproject commit dec6a9ecab3e5ec9ceff28b84cabb5c62d05ee9f
|
@ -1 +1 @@
|
|||||||
Subproject commit 5b52a0f395065d6cb7b65a00a5e17eaf9ebd64d5
|
Subproject commit ef99f1d90cdb33a52931aed5868785b51fb9411d
|
@ -1 +1 @@
|
|||||||
Subproject commit 038e3a6ca59f11b3bb6a94087c1792322d1a1d5c
|
Subproject commit a532fed72ace069e61c0132125b728316f9abd3c
|
@ -1 +1 @@
|
|||||||
Subproject commit da928a4c6b65148bfda3138674da1730c143f396
|
Subproject commit 328bcb32590e5057b09bd27a40bc2fb21385fbf3
|
@ -1 +1 @@
|
|||||||
Subproject commit a30145b0f82d06770e924e9eac064ed223a94e6b
|
Subproject commit b474978b2e9435c10ca66f8281352ebc825264f4
|
@ -1 +1 @@
|
|||||||
Subproject commit d698aee479f7fd5ce635568aa9892380d80f8ed7
|
Subproject commit 462ef27cf39db4a837eeecf7135fb65cd0b8789a
|
@ -1 +1 @@
|
|||||||
Subproject commit 3364d4d147ade148d8e5dd67609e46f0ef6c50fc
|
Subproject commit 20230402d087858ca9a93aa8fe53d289f29c1836
|
@ -1 +1 @@
|
|||||||
Subproject commit 5dccd1801f36efb14e6b43ad90cb9569fe220d1c
|
Subproject commit 6d96a8a4906e91f44ddf97645d5c3c1980212402
|
@ -1 +1 @@
|
|||||||
Subproject commit cb8bdd3e43b50a0610cff3a69959cb27eb407afc
|
Subproject commit 020bbf7d64cc2f0c5d2a4ab96d45b8014ef54ad2
|
Loading…
Reference in New Issue