Browse Source

Add directory choosing

master
= 3 years ago
parent
commit
401c511f8f
2 changed files with 30 additions and 0 deletions
  1. +20
    -0
      mru
  2. +10
    -0
      prompt

+ 20
- 0
mru View File

@@ -40,6 +40,15 @@ update() {
rm_recent "$1" 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 # This remove duplicates by deleting files in recent from the main file
rm_recent() { rm_recent() {
file=$XDG_CACHE_HOME/mru/$1 file=$XDG_CACHE_HOME/mru/$1
@@ -66,6 +75,15 @@ list() {
output "$1" | cut -f3 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() { insert() {
if [ -z "$1" ]; then printf "No path given\n" 1>&2; exit; fi if [ -z "$1" ]; then printf "No path given\n" 1>&2; exit; fi
cache_name=$2 cache_name=$2
@@ -94,7 +112,9 @@ insert() {
case "$1" in case "$1" in
init) init "$2";; init) init "$2";;
update) update $2;; update) update $2;;
updatedirs) updatedirs "$2";;
output) output "$2";; output) output "$2";;
list) list "$2";; list) list "$2";;
listdirs) listdirs "$2";;
insert) insert "$2" "$3";; insert) insert "$2" "$3";;
esac esac

+ 10
- 0
prompt View File

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


Loading…
Cancel
Save