From 826c320851f0afa06f465cc9fed698b86461eb40 Mon Sep 17 00:00:00 2001 From: Kevin Mok Date: Wed, 5 Dec 2018 21:31:21 -0500 Subject: [PATCH] Simplified setup.sh --- aliases/zsh_aliases | 4 ++-- scripts/tex-clean | 20 +++++++++-------- setup.sh | 42 +++++++++--------------------------- txt/key_dirs.txt | 4 ++-- txt/pacman-pkgs/aur-pkgs.txt | 1 + 5 files changed, 26 insertions(+), 45 deletions(-) diff --git a/aliases/zsh_aliases b/aliases/zsh_aliases index 260c4a2..2f76b89 100644 --- a/aliases/zsh_aliases +++ b/aliases/zsh_aliases @@ -33,7 +33,7 @@ function gpdf() { pdfgrep -n -e $1 $2 } # for finding files by name -function rf() { find . -name '$1' ; } +export FZF_DEFAULT_COMMAND='ag --hidden --ignore .git -g ""' # find text inside files function rg() { grep -nr $1 ; } function cpd() { cp -avr $1 $2 ; } @@ -357,7 +357,7 @@ alias s="cs && shellcheck" # school {{{ # alias pdl="pdflatex" -alias tcl="texclear" +alias tcl="tex-clean" # 343 alias ij="sudo ~/Downloads/idea/bin/idea.sh $silent" diff --git a/scripts/tex-clean b/scripts/tex-clean index 65dfb1b..9380259 100755 --- a/scripts/tex-clean +++ b/scripts/tex-clean @@ -4,20 +4,22 @@ # remove from there. ext_list="/home/kevin/linux-config/txt/tex-build-files.txt" -raw_exts="$(tr '\n' '|' < $ext_list)" -exts="(${raw_exts::-1})" -# echo "$exts" +raw_build_exts="$(tr '\n' '|' < $ext_list)" +build_exts="(${raw_build_exts::-1})" +# echo "$build_exts" find_flags=(-maxdepth 1 -type f -regextype gnu-awk -regex) +# match all files with build extensions +regex=(\"^.*\\."$build_exts"$\") remove_build_files () { - regex=$2 - # echo find "$1" "${find_flags[@]}" "$regex" -delete -print - eval find "$1" "${find_flags[@]}" "$regex" -delete -print + regex=("$2") + # eval find "$1" "${find_flags[@]}" "${regex[0]}" -delete -print + eval find "$1" "${find_flags[@]}" "${regex[0]}" -delete } # when less than one argument, remove build files in current dir if [[ "$#" -lt 1 ]]; then - regex=(\"^.*\\."$exts"$\") + regex=(\"^.*\\."$build_exts"$\") remove_build_files . "${regex[0]}" else case "$1" in @@ -26,12 +28,12 @@ else file=$(readlink -f "$1") dir=$(dirname "$file") base="${file%.*}" - regex=(\"^"$base"\\."$exts"$\") + # remove build files matching file name + regex=(\"^"$base"\\."$build_exts"$\") remove_build_files "$dir" "${regex[0]}" ;; # remove all build files in directory if given valid one *) if [[ -d "$1" ]]; then - regex=(\"^.*\\."$exts"$\") remove_build_files "$1" "${regex[0]}" else printf "Give .tex file or directory as argument.\\n" diff --git a/setup.sh b/setup.sh index c4a477c..f4659a2 100755 --- a/setup.sh +++ b/setup.sh @@ -1,7 +1,5 @@ #!/bin/bash -# vars {{{ # - shopt -s dotglob lc_dir="/home/kevin/linux-config" @@ -10,46 +8,26 @@ link_to_lc () { echo "Linking $1 from $3 to $2." sys_dir="$2" config_dir="$3" + items=() case "$1" in - -# }}} vars # - - # files {{{ # - files) - for file in "$config_dir"/*; do - file_name=$(basename -- "$file") - # echo "$file_name" - # Remove system file and link config in repository to system. - rm -f "${sys_dir:?}"/"$file_name" - ln -s "$config_dir"/"$file_name" "$sys_dir"/"$file_name" && echo "Linked $file_name." - done ;; - - # }}} files # - - # dirs {{{ # - + items="$config_dir"/* ;; dirs) - for dir in "$config_dir"/*/; do - dir_name=$(basename -- "$dir") - # echo "$dir_name" - rm -f "${sys_dir:?}"/"$dir_name" - ln -s "$config_dir"/"$dir_name" "$sys_dir"/"$dir_name" && echo "Linked $dir_name." - done ;; - - # }}} dirs # - -# run commands {{{ # - + items="$config_dir"/*/ ;; esac + for item in $items; do + item_name=$(basename -- "$item") + # echo "$item_name" + # Remove system item and link config in repository to system. + rm -f "${sys_dir:?}"/"$item_name" + ln -s "$config_dir"/"$item_name" "$sys_dir"/"$item_name" && echo "Linked $item_name." + done } link_to_lc "files" "$HOME" "$lc_dir/dotfiles" link_to_lc "dirs" "$HOME/.config" "$lc_dir/configs" link_to_lc "dirs" "$HOME/.themes" "$lc_dir/gtk/themes" -# }}} run # - # setup nvim config {{{ # # nvim_file="/home/kevin/lc-test/init.vim" diff --git a/txt/key_dirs.txt b/txt/key_dirs.txt index c9f2a41..b786bc4 100644 --- a/txt/key_dirs.txt +++ b/txt/key_dirs.txt @@ -1,7 +1,7 @@ # sys {{{ * bg /home/kevin/Pictures/Backgrounds -cn /home/kevin/.config +co /home/kevin/.config lc /home/kevin/linux-config/ d /home/kevin/Downloads D /home/kevin/Documents @@ -14,7 +14,7 @@ o / # cdn {{{ * -co /home/kevin/coding +cn /home/kevin/coding j /home/kevin/Documents/journal ib /home/kevin/linux-config/configs/i3blocks-scripts ra /home/kevin/linux-config/configs/ranger diff --git a/txt/pacman-pkgs/aur-pkgs.txt b/txt/pacman-pkgs/aur-pkgs.txt index eba2495..6bbcf81 100644 --- a/txt/pacman-pkgs/aur-pkgs.txt +++ b/txt/pacman-pkgs/aur-pkgs.txt @@ -3,4 +3,5 @@ texlive-localmanager-git gscreenshot rxvt-unicode-pixbuf Hack NF +the_silver_searcher trizen