Add dot files
This commit is contained in:
parent
4da895e719
commit
0dd4976210
91 changed files with 20968 additions and 542 deletions
|
|
@ -7,7 +7,6 @@ source $HOME/bashscripts/message.bash
|
|||
_execBeforePrompt(){
|
||||
|
||||
echo -ne "\033]0;${PWD/$HOME/~}\007"
|
||||
_cache "d$PWD"
|
||||
}
|
||||
|
||||
ds(){
|
||||
|
|
@ -30,7 +29,7 @@ _restoreIFS(){
|
|||
}
|
||||
|
||||
_ut ()
|
||||
{
|
||||
{
|
||||
SIFS=$IFS
|
||||
IFS=$'/\t\n'
|
||||
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||
|
|
@ -42,67 +41,16 @@ _ut ()
|
|||
}
|
||||
complete -F _ut ut
|
||||
|
||||
cacheFile="$(eval echo ~${USER})/.jdcache"
|
||||
|
||||
_cache(){
|
||||
path="$1"
|
||||
if [[ $PWD == "/" ]]; then
|
||||
path=$(echo "$1" | sed -e '0,/\//s/\///')
|
||||
fi
|
||||
if [ -z "$1" ]; then
|
||||
cat $cacheFile
|
||||
|
||||
else
|
||||
touch $cacheFile
|
||||
#for var in $1; do
|
||||
isin=$(_cachecontains $path)
|
||||
if [ $isin -eq 0 ]; then
|
||||
echo "$path" >> $cacheFile
|
||||
fi
|
||||
#done >> $cacheFile
|
||||
fi
|
||||
}
|
||||
|
||||
_cachecontains(){
|
||||
touch $cacheFile
|
||||
if [ -n "$1" ]; then
|
||||
a=$(grep "$1" $cacheFile)
|
||||
if [ -n "$a" ]; then
|
||||
echo 1
|
||||
return
|
||||
fi
|
||||
fi
|
||||
echo 0
|
||||
|
||||
}
|
||||
|
||||
_cachefind(){
|
||||
touch $cacheFile
|
||||
fType=$2
|
||||
query=$1
|
||||
if [[ "$query" != "" ]]; then
|
||||
grep "^$fType" $cacheFile | sed -e 's/.\(.*\)/\1/' | grep -i "$query"
|
||||
if [[ "$?" == "1" ]];then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
#while read line
|
||||
#do
|
||||
# echo hi $line
|
||||
# done <<< "`ls -1d *`"
|
||||
|
||||
#ls -1RAp | grep -v /\$
|
||||
jd(){
|
||||
SAVEIFS=$IFS
|
||||
IFS=$(echo -en "\n\b")
|
||||
#grabs all of the folders in the current subdirectory
|
||||
local suffix=""
|
||||
local insensitive="-i"
|
||||
OPTIND=1
|
||||
while getopts "hf:s:p:" flag
|
||||
do
|
||||
while getopts "hf:s:p:t" flag
|
||||
do
|
||||
case $flag in
|
||||
h)
|
||||
_jdhelp
|
||||
|
|
@ -116,11 +64,18 @@ jd(){
|
|||
p)
|
||||
suffix="$OPTARG"
|
||||
;;
|
||||
t)
|
||||
insensitive=""
|
||||
;;
|
||||
s)
|
||||
grep --color=always --include="*$suffix" -r -n -i "$OPTARG" * | sed -e "s/:/ +/" | sed -e "s/:/ --/" | sed -e "s/^/vim /"
|
||||
grep --color=always --exclude-dir=".webassets-cache" \
|
||||
--exclude-dir="dist" \
|
||||
--exclude-dir="node_modules" --include="*$suffix" \
|
||||
-r -n $insensitive "$OPTARG" * | \
|
||||
sed -e "s/:/ +/" | sed -e "s/:/ --/" | sed -e "s/^/vim /"
|
||||
return
|
||||
;;
|
||||
|
||||
|
||||
\?)
|
||||
echo Invalid argument.
|
||||
_jdhelp
|
||||
|
|
@ -146,54 +101,28 @@ _jdhelp(){
|
|||
|
||||
echo
|
||||
echo "jd [-f] QUERY [depth]"
|
||||
echo
|
||||
|
||||
echo
|
||||
|
||||
echo "Search for files or folders."
|
||||
|
||||
printf "%-20s %-30s\n" "-f" "Searches files instead of directories"
|
||||
printf "%-20s %-30s\n" "-h" "Display this message"
|
||||
printf "%-20s %-30s\n" "-s" "Search files recursively in current dir."
|
||||
printf "%-20s %-30s\n" "depth" "A number from 0-N that specifies the depth to search."
|
||||
printf "%-20s %-30s\n" "depth" "A number from 0-N that specifies the depth to search."
|
||||
printf "%-20s %-50s\n" "" "No flag is needed, just enter the number after the query."
|
||||
|
||||
}
|
||||
|
||||
_jd(){
|
||||
|
||||
SAVEIFS=$IFS
|
||||
IFS=$(echo -en "\n\b")
|
||||
|
||||
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||
cur=${cur//\"/}
|
||||
|
||||
ftype=${COMP_WORDS[1]}
|
||||
|
||||
if [[ "$ftype" == "-f" ]]; then
|
||||
fs=$(_cachefind "$cur" "f" )
|
||||
else
|
||||
fs=$(_cachefind "$cur" "d" )
|
||||
fi
|
||||
|
||||
t=$(printf "%s\n\b" "$fs" | grep -i "$cur" )
|
||||
|
||||
COMPREPLY=( $( compgen -P\" -S\" -W "$t" -X "\!*$cur*" ) )
|
||||
|
||||
IFS=$SAVEIFS
|
||||
|
||||
}
|
||||
|
||||
complete -F _jd jd
|
||||
|
||||
_findDirs(){
|
||||
query=${1//\*/\.\*}
|
||||
fType="$2"
|
||||
depth="$3"
|
||||
|
||||
|
||||
if [[ $fType == "d" ]]; then
|
||||
|
||||
if [[ "$depth" == "" ]]; then
|
||||
|
||||
direcs=$(ls -AR 2>/dev/null | grep ":$" | sed -e 's/\(.*\)./\1/' -e 's/..\(.*\)/\1/')
|
||||
|
||||
direcs=$(ls -AR 2>/dev/null | grep ":$" | sed -e 's/\(.*\)./\1/' -e 's/..\(.*\)/\1/')
|
||||
|
||||
else
|
||||
if [ $depth -gt 4 ]; then
|
||||
|
|
@ -230,7 +159,7 @@ _findDirs(){
|
|||
cd $query
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
if [ $numElements -gt 0 ]; then
|
||||
echo
|
||||
|
||||
|
|
@ -243,85 +172,11 @@ _findDirs(){
|
|||
fi
|
||||
}
|
||||
|
||||
_checkCache(){
|
||||
fType=$2
|
||||
query=${1//\*/\.\*}
|
||||
ccont="$(_cachefind "$query" "$fType")"
|
||||
if [[ "$?" != "0" ]];then
|
||||
relevantDirs=($(printf "%s\n" "$ccont" | grep -i "$query"))
|
||||
numElements=${#relevantFolders[@]}
|
||||
|
||||
if [[ "${relevantDirs[0]}" == "$query" ]]; then
|
||||
|
||||
echo $query
|
||||
|
||||
|
||||
if [[ $fType == "f" ]];then
|
||||
xdg-open $query 2>/dev/null
|
||||
return 0
|
||||
fi
|
||||
|
||||
cd $query
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
echo
|
||||
|
||||
printf "%s\n" "$ccont" | grep -i "$query" | sed '/./=' | sed '/./N; s/\n/ - /' | grep -i "$query"
|
||||
|
||||
echo
|
||||
|
||||
if [[ $fType == "d" ]]; then
|
||||
read -p "Which cached folder? (Enter a number, c to continue to search, or q to quit) " fold
|
||||
else
|
||||
read -p "Which cached file? (Enter a number, c to continue to search, or q to quit) " fold
|
||||
fi
|
||||
|
||||
if [ "$fold" == "" ] || [[ "$fold" == "c" ]];then
|
||||
return 1
|
||||
elif [ "$fold" == "q" ];then
|
||||
return 0
|
||||
elif ! [[ "$fold" =~ ^[0-9]+$ ]] ; then
|
||||
exec >&2; echo "error: Not a number"; return 0
|
||||
else
|
||||
choice=${relevantDirs[$((fold-1))]}
|
||||
fi
|
||||
|
||||
if [[ $fType == "f" ]];then
|
||||
read -p "Which application would you like to open it with? (Enter for default)" app
|
||||
fi
|
||||
|
||||
echo
|
||||
|
||||
if [[ "$fold" != "" ]] && [[ $fold != "c" ]];then
|
||||
echo $choice
|
||||
|
||||
|
||||
if [[ $fType == "f" ]];then
|
||||
if [ "$app" == "" ]; then
|
||||
xdg-open $choice 2>/dev/null
|
||||
|
||||
else
|
||||
$app $choice 2>/dev/null
|
||||
fi
|
||||
|
||||
return 0
|
||||
fi
|
||||
|
||||
cd $choice
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
return 1
|
||||
|
||||
}
|
||||
|
||||
rme(){
|
||||
patt="$1"
|
||||
except="$2"
|
||||
|
||||
epatt=$(ls | grep "$1.*$2")
|
||||
epatt=$(ls | grep "$1.*$2")
|
||||
|
||||
rms=$(ls | grep $1)
|
||||
|
||||
|
|
@ -333,34 +188,3 @@ rme(){
|
|||
done
|
||||
|
||||
}
|
||||
|
||||
q(){
|
||||
sysname="$1"
|
||||
testing="\/home\/runner\/testing\/"
|
||||
relSys=($(compgen -d $testing | cut -d/ -f5 | grep -i $sysname))
|
||||
relDirs=($(compgen -d $testing | grep -i $sysname | sed -e "s/$/\/queue/"))
|
||||
message $sysname relSys[@] relDirs[@] "Which queue folder would you like to go to?" "cd"
|
||||
|
||||
}
|
||||
|
||||
_q(){
|
||||
|
||||
#SAVEIFS=$IFS
|
||||
#IFS=$(echo -en "\n\b")
|
||||
|
||||
sysname="$1"
|
||||
direcs="$(compgen -d "\/home\/runner\/testing\/" | cut -d/ -f5)"
|
||||
|
||||
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||
|
||||
fs=$direcs
|
||||
|
||||
t=$(printf "%s\n\b" "$fs" | grep -i "$cur" )
|
||||
|
||||
COMPREPLY=( $( compgen -W "${direcs}" -- ${cur} ) )
|
||||
|
||||
#IFS=$SAVEIFS
|
||||
|
||||
}
|
||||
complete -F _q q
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue