From f27e393c4bf15c4ce976913afbf962a0ce5fd217 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Thu, 31 Dec 2020 12:18:33 +0100 Subject: [PATCH] improved ce like de --- .local/bin/tools/ce | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/.local/bin/tools/ce b/.local/bin/tools/ce index 41bf2b8..cbb820f 100755 --- a/.local/bin/tools/ce +++ b/.local/bin/tools/ce @@ -1,18 +1,28 @@ #!/bin/bash -currentdir="$(pwd)" -#file="$( du -a ~/.config/* ~/.local/src/* ~/.local/bin/* | awk '{print $2}' | fzf -e --query="$*")" -#[ "$file" = "" ] || ( cd "$( dirname "$file" )" && $EDITOR "$file" && cd "$currentdir" ) +#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}' )" -#/bin/sh probably means we're in dmenu_run +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 ~/.config/* ~/.local/src/* ~/.local/bin/* | awk '{print $2}' | dmenu -l 10 -p 'open what file?' )" + file="$( du -a $document_dirs | awk '{for(i=2; i