Kaynağa Gözat

Add directory choosing

master
= 3 yıl önce
ebeveyn
işleme
401c511f8f
2 değiştirilmiş dosya ile 30 ekleme ve 0 silme
  1. +20
    -0
      mru
  2. +10
    -0
      prompt

+ 20
- 0
mru Dosyayı Görüntüle

@@ -40,6 +40,15 @@ update() {
rm_recent "$1"
}

updatedirs() {
cache_name="$1"
if [ -z "$1" ]; then cache_name=home; fi
path="$(printf $cache_info | grep "^$cache_name" - | cut -d: -f2)"
if [ -z "$path" ]; then printf "invalid cache name: $1\n" 1>&2; exit; fi

list "$1" | sed -n 's:\(.*\)/.*$:\1:p' | sort -u >$XDG_CACHE_HOME/mru/"$cache_name.dirs"
}

# This remove duplicates by deleting files in recent from the main file
rm_recent() {
file=$XDG_CACHE_HOME/mru/$1
@@ -66,6 +75,15 @@ list() {
output "$1" | cut -f3
}

listdirs() {
cache_name="$1"
if [ -z "$1" ]; then cache_name=home; fi
path="$(printf $cache_info | grep "^$cache_name" - | cut -d: -f2)"
if [ -z "$path" ]; then printf "invalid cache name: $1\n" 1>&2; exit; fi

cat $XDG_CACHE_HOME/mru/"$cache_name.dirs"
}

insert() {
if [ -z "$1" ]; then printf "No path given\n" 1>&2; exit; fi
cache_name=$2
@@ -94,7 +112,9 @@ insert() {
case "$1" in
init) init "$2";;
update) update $2;;
updatedirs) updatedirs "$2";;
output) output "$2";;
list) list "$2";;
listdirs) listdirs "$2";;
insert) insert "$2" "$3";;
esac

+ 10
- 0
prompt Dosyayı Görüntüle

@@ -54,6 +54,7 @@ action() {
Command
Command to clipboard
Choose
Choosedir
Select VPN
Disable VPN
Enable VPN
@@ -77,6 +78,7 @@ action() {
'Enable Bar') tmux set -g status on;;
'Command') cmd;;
'Choose') chooser;;
'Choosedir') choosedir;;
'Command to clipboard') cmd_clip;;
'Username') username;;
'Password') password;;
@@ -332,6 +334,14 @@ chooser() {
$c "$f"
}

choosedir(){
f=$(mru listdirs | dmenu -i -l 20 -p 'choose dir')
if [ -z "$f" ]; then exit; fi
c=$(dmenu_path | dmenu -i -p 'operation')
if [ -z $c ]; then exit; fi
$c "$f"
}

vpn() {
ls
}


Yükleniyor…
İptal
Kaydet