can open multiple files simultaneously now

This commit is contained in:
Alexander Bocken 2021-01-04 16:31:18 +01:00
parent f4e4a591b2
commit 1704fe27fe
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8

View File

@ -3,10 +3,10 @@
#either via dmenu or fzf depending on the context
ppid () { ps -p ${1:-$$} -o ppid=; }
shell="$(ps aux | grep $( ppid ) | head -n1 | awk '{print $11}' )"
document_dirs="$HOME/bks/* $HOME/eth/* $HOME/dox/*"
document_dirs="$HOME/bks/* $HOME/eth/* $HOME/dox/* $HOME/dls/*"
#force launch dmenu via cmd
if [ "$1" = "launchdmenu" ]; then
file="$( find $document_dirs -type f | sed "s|$HOME|~|"| dmenu -l 10 -p 'open what file?')"
file="$( find $document_dirs -type f | sed "s|$HOME|~|"| dmenu -i -l 10 -p 'open what file?')"
#/bin/sh means it's probably from dmenu_run (it's ugly but works)
elif [ ! "$shell" = "/bin/sh" ]; then
currentdir="$(pwd)"
@ -17,23 +17,21 @@ elif [ ! "$shell" = "/bin/sh" ]; then
if rifle -l "$path" | head -n1 | grep -q 'EDITOR';then
rifle "$path"
else
rifle "$path" & disown
rifle "$path" &
fi
cd "$currentdir" || exit
exit
#launch dmenu as it's probably in dmenu_run
else
file="$( find $document_dirs -type f | sed "s|$HOME|~|" | dmenu -l 10 -p 'open what file?' -it "$*" )"
file="$( find $document_dirs -type f | sed "s|$HOME|~|" | dmenu -i -l 10 -p 'open what file?' -it "$*" )"
fi
#process selection if it's from dmenu
[ -z "$file" ] && exit
path="$(echo "$file" | sed "s|\~|$HOME|")"
echo "$path" |
echo "$file" | sed "s|\~|$HOME|" |
while read -r pathfile; do
cd "$( dirname "$pathfile" )" || exit
if rifle -l "$pathfile" | head -n1 | grep -q 'EDITOR';then
st rifle "$pathfile"
st rifle "$pathfile" &
else
rifle "$pathfile"
rifle "$pathfile" &
fi
done