various smaller changes
Changes to be committed: modified: .config/aliasrc modified: .config/mpv/input.conf modified: .config/zathura/zathurarc modified: .local/bin/bt modified: .local/bin/statusbar/clock modified: .local/bin/tools/ce deleted: .local/bin/tools/ripper modified: .local/bin/tools/wv deleted: .local/bin/transadd
This commit is contained in:
@ -1,28 +1,31 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
#A script that launches documents in their respective viewers
|
||||
#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/.config/* $HOME/.local/src/* $HOME/.local/bin/*"
|
||||
#/bin/sh means it's probably from dmenu_run (it's ugly but works)
|
||||
if [ "$shell" = "/bin/sh" ]; then
|
||||
file="$( du -a $document_dirs | awk '{for(i=2; i<NF; i++){printf("%s ", $i)}printf("%s\n", $NF)}'| dmenu -l 10 -p 'open what file?' -it "$*" )"
|
||||
[ -z "$file" ] && exit
|
||||
cd "$( dirname "$file" )" || exit
|
||||
if rifle -l "$file" | head -n1 | grep -q 'EDITOR';then
|
||||
st rifle "$file"
|
||||
else
|
||||
rifle "$file"
|
||||
fi
|
||||
else
|
||||
if [ ! "$shell" = "/bin/sh" ]; then
|
||||
currentdir="$(pwd)"
|
||||
file="$( du -a $document_dirs | awk '{for(i=2; i<NF; i++){printf("%s ", $i)}printf("%s\n", $NF)}' | fzf -e --query="$*")"
|
||||
file="$( find $document_dirs -type f | sed "s|$HOME|~|" | fzf -e --query="$*")"
|
||||
path="$(printf '%s%s' "$HOME" "${file//\~/}")"
|
||||
[ -z "$file" ] && exit
|
||||
cd "$( dirname "$file" )" || exit
|
||||
if rifle -l "$file" | head -n1 | grep -q 'EDITOR';then
|
||||
rifle "$file"
|
||||
cd "$( dirname "$path" )" || exit
|
||||
if rifle -l "$path" | head -n1 | grep -q 'EDITOR';then
|
||||
rifle "$path"
|
||||
else
|
||||
rifle "$file" & disown
|
||||
rifle "$path" &
|
||||
fi
|
||||
cd "$currentdir" || 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 "$*" )"
|
||||
[ -z "$file" ] && exit
|
||||
path="$(printf '%s%s' "$HOME" "${file//\~/}")"
|
||||
cd "$( dirname "$path" )" || exit
|
||||
if rifle -l "$path" | head -n1 | grep -q 'EDITOR';then
|
||||
st rifle "$path" &
|
||||
else
|
||||
rifle "$path" &
|
||||
fi
|
||||
fi
|
||||
|
Reference in New Issue
Block a user