From 713d34790446fdd8401842fed36e2c151434a0e7 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Thu, 6 May 2021 17:21:41 +0200 Subject: [PATCH] de filters out ranger tagged files --- .local/bin/tools/de | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.local/bin/tools/de b/.local/bin/tools/de index 83dc4fd..d316563 100755 --- a/.local/bin/tools/de +++ b/.local/bin/tools/de @@ -1,16 +1,20 @@ -#!/bin/sh +#!/bin/bash #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/bks/* $HOME/eth/* $HOME/dox/* $HOME/dls/*" +#personally I don't want any files tagged with 'w' in ranger listed. (Watched videos) +tagged_file="${XDG_DATA_HOME:-$HOME/.local/share}/ranger/tagged" +filterfile="/tmp/tagged_filter" +grep -E '^w\:' "$tagged_file" | sed -E 's/^w\://' > "$filterfile" #force launch dmenu via cmd if [ "$1" = "launchdmenu" ]; then - file="$( find $document_dirs -type f | sed "s|$HOME|~|"| dmenu -i -l 10 -p 'open what file?')" + file="$( find $document_dirs -type f | grep -vf "$filterfile" | 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)" - file="$( find $document_dirs -type f | sed "s|$HOME|~|" | fzf -e --query="$*")" + file="$( find $document_dirs -type f | grep -vf "$filterfile" | sed "s|$HOME|~|" | fzf -e --query="$*")" path="$(printf '%s%s' "$HOME" "${file//\~/}")" [ -z "$file" ] && exit cd "$( dirname "$path" )" || exit @@ -23,7 +27,7 @@ elif [ ! "$shell" = "/bin/sh" ]; then exit #launch dmenu as it's probably in dmenu_run else - file="$( find $document_dirs -type f | sed "s|$HOME|~|" | dmenu -i -l 10 -p 'open what file?' -it "$*" )" + file="$( find $document_dirs -type f | grep -vf "$filterfile" | sed "s|$HOME|~|" | dmenu -i -l 10 -p 'open what file?' -it "$*" )" fi #process selection if it's from dmenu [ -z "$file" ] && exit @@ -35,3 +39,4 @@ echo "$file" | sed "s|\~|$HOME|" | rifle "$pathfile" & fi done +rm "$filterfile"