update
This commit is contained in:
+1
-1
@@ -35,7 +35,7 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|||||||
file=$(pwd)/$1
|
file=$(pwd)/$1
|
||||||
fi
|
fi
|
||||||
gsettings set org.gnome.desktop.background picture-uri file://$file
|
gsettings set org.gnome.desktop.background picture-uri file://$file
|
||||||
}
|
}
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,17 @@
|
|||||||
# Add the command to desired list
|
# Add the command to desired list
|
||||||
|
|
||||||
# fzf match everything
|
# fzf match everything
|
||||||
|
fzf_command_list_all=(\
|
||||||
|
)
|
||||||
|
|
||||||
|
# fzf match files
|
||||||
fzf_command_list_file=(\
|
fzf_command_list_file=(\
|
||||||
|
cat \
|
||||||
vim \
|
vim \
|
||||||
set_wallpaper \
|
set_wallpaper \
|
||||||
)
|
)
|
||||||
|
|
||||||
# fzf only match folder
|
# fzf only match folders
|
||||||
fzf_command_list_dir=(\
|
fzf_command_list_dir=(\
|
||||||
ls \
|
ls \
|
||||||
cd \
|
cd \
|
||||||
@@ -19,6 +24,9 @@ cd \
|
|||||||
|
|
||||||
# in case above functions are broken
|
# in case above functions are broken
|
||||||
no_fzf(){
|
no_fzf(){
|
||||||
|
for c in "${fzf_command_list_all[@]}"; do
|
||||||
|
unalias $c
|
||||||
|
done
|
||||||
for c in "${fzf_command_list_file[@]}"; do
|
for c in "${fzf_command_list_file[@]}"; do
|
||||||
unalias $c
|
unalias $c
|
||||||
done
|
done
|
||||||
@@ -28,12 +36,13 @@ no_fzf(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
dp(){
|
dp(){
|
||||||
local debug=0
|
local debug=1
|
||||||
[ "$debug" = "1" ] && echo $1
|
[ "$debug" = "1" ] && echo $1
|
||||||
}
|
}
|
||||||
|
|
||||||
# SHELL specific setting
|
# SHELL specific setting
|
||||||
if [ ! -z "$ZSH_NAME" ]; then
|
if [ ! -z "$ZSH_NAME" ]; then
|
||||||
|
dp "[bash_tools]: In ZSH shell"
|
||||||
# disable error output when
|
# disable error output when
|
||||||
# wildcard found 0 match
|
# wildcard found 0 match
|
||||||
setopt +o nomatch
|
setopt +o nomatch
|
||||||
@@ -42,9 +51,20 @@ if [ ! -z "$ZSH_NAME" ]; then
|
|||||||
# use in fzf_selector
|
# use in fzf_selector
|
||||||
# only for zsh
|
# only for zsh
|
||||||
setopt dotglob
|
setopt dotglob
|
||||||
|
setopt glob_dots
|
||||||
|
|
||||||
else
|
else
|
||||||
|
dp "[bash_tools]: In non-ZSH shell"
|
||||||
# only for bash
|
# only for bash
|
||||||
shopt -s dotglob
|
shopt -s dotglob
|
||||||
|
|
||||||
|
# allow reverse wildcard exp. !(b*)
|
||||||
|
# shopt -u extglob
|
||||||
|
|
||||||
|
# allows filename patterns which match no
|
||||||
|
# files to expand to a null string, rather
|
||||||
|
# than themselves
|
||||||
|
shopt -s nullglob
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ret=''
|
ret=''
|
||||||
@@ -52,7 +72,8 @@ ret=''
|
|||||||
# $1 keyword
|
# $1 keyword
|
||||||
# $2
|
# $2
|
||||||
# 0: show all
|
# 0: show all
|
||||||
# 1: only show directory
|
# 1: only show directories
|
||||||
|
# 2: only show files
|
||||||
fzf_selector() {
|
fzf_selector() {
|
||||||
ret=$1
|
ret=$1
|
||||||
if [ "$1" = "." ] || [ "$1" = ".." ] || \
|
if [ "$1" = "." ] || [ "$1" = ".." ] || \
|
||||||
@@ -63,8 +84,18 @@ fzf_selector() {
|
|||||||
if [ $2 = 0 ]; then
|
if [ $2 = 0 ]; then
|
||||||
all_items=(*)
|
all_items=(*)
|
||||||
elif [ $2 = 1 ]; then
|
elif [ $2 = 1 ]; then
|
||||||
all_items=(*/) 2>&1
|
dp "try to find dirs"
|
||||||
|
all_items=(*/)
|
||||||
|
elif [ $2 = 2 ]; then
|
||||||
|
dp "try to find files"
|
||||||
|
all=(*)
|
||||||
|
all_items=()
|
||||||
|
for item in "${all[@]}"; do
|
||||||
|
grep -P *$1*[^/]$ <<< $item > /dev/null 2>&1 && \
|
||||||
|
all_items+=("$item")
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
dp "${all_items[@]}"
|
||||||
#shopt -u dotglob
|
#shopt -u dotglob
|
||||||
|
|
||||||
files=()
|
files=()
|
||||||
@@ -127,9 +158,12 @@ fzf_command_execute() {
|
|||||||
${args[@]} "$ret"
|
${args[@]} "$ret"
|
||||||
}
|
}
|
||||||
|
|
||||||
for c in "${fzf_command_list_file[@]}"; do
|
for c in "${fzf_command_list_all[@]}"; do
|
||||||
alias $c="fzf_command_execute $c 0"
|
alias $c="fzf_command_execute $c 0"
|
||||||
done
|
done
|
||||||
|
for c in "${fzf_command_list_file[@]}"; do
|
||||||
|
alias $c="fzf_command_execute $c 2"
|
||||||
|
done
|
||||||
for c in "${fzf_command_list_dir[@]}"; do
|
for c in "${fzf_command_list_dir[@]}"; do
|
||||||
alias $c="fzf_command_execute $c 1"
|
alias $c="fzf_command_execute $c 1"
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user