Browse Source

Simplified setup.sh

red-hat-laptop
Kevin Mok 6 years ago
parent
commit
826c320851
  1. 4
      aliases/zsh_aliases
  2. 20
      scripts/tex-clean
  3. 42
      setup.sh
  4. 4
      txt/key_dirs.txt
  5. 1
      txt/pacman-pkgs/aur-pkgs.txt

4
aliases/zsh_aliases

@ -33,7 +33,7 @@ function gpdf() {
pdfgrep -n -e $1 $2 pdfgrep -n -e $1 $2
} }
# for finding files by name # for finding files by name
function rf() { find . -name '$1' ; }
export FZF_DEFAULT_COMMAND='ag --hidden --ignore .git -g ""'
# find text inside files # find text inside files
function rg() { grep -nr $1 ; } function rg() { grep -nr $1 ; }
function cpd() { cp -avr $1 $2 ; } function cpd() { cp -avr $1 $2 ; }
@ -357,7 +357,7 @@ alias s="cs && shellcheck"
# school {{{ # # school {{{ #
alias pdl="pdflatex" alias pdl="pdflatex"
alias tcl="texclear"
alias tcl="tex-clean"
# 343 # 343
alias ij="sudo ~/Downloads/idea/bin/idea.sh $silent" alias ij="sudo ~/Downloads/idea/bin/idea.sh $silent"

20
scripts/tex-clean

@ -4,20 +4,22 @@
# remove from there. # remove from there.
ext_list="/home/kevin/linux-config/txt/tex-build-files.txt" 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) find_flags=(-maxdepth 1 -type f -regextype gnu-awk -regex)
# match all files with build extensions
regex=(\"^.*\\."$build_exts"$\")
remove_build_files () { 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 # when less than one argument, remove build files in current dir
if [[ "$#" -lt 1 ]]; then if [[ "$#" -lt 1 ]]; then
regex=(\"^.*\\."$exts"$\")
regex=(\"^.*\\."$build_exts"$\")
remove_build_files . "${regex[0]}" remove_build_files . "${regex[0]}"
else else
case "$1" in case "$1" in
@ -26,12 +28,12 @@ else
file=$(readlink -f "$1") file=$(readlink -f "$1")
dir=$(dirname "$file") dir=$(dirname "$file")
base="${file%.*}" base="${file%.*}"
regex=(\"^"$base"\\."$exts"$\")
# remove build files matching file name
regex=(\"^"$base"\\."$build_exts"$\")
remove_build_files "$dir" "${regex[0]}" ;; remove_build_files "$dir" "${regex[0]}" ;;
# remove all build files in directory if given valid one # remove all build files in directory if given valid one
*) *)
if [[ -d "$1" ]]; then if [[ -d "$1" ]]; then
regex=(\"^.*\\."$exts"$\")
remove_build_files "$1" "${regex[0]}" remove_build_files "$1" "${regex[0]}"
else else
printf "Give .tex file or directory as argument.\\n" printf "Give .tex file or directory as argument.\\n"

42
setup.sh

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
# vars {{{ #
shopt -s dotglob shopt -s dotglob
lc_dir="/home/kevin/linux-config" lc_dir="/home/kevin/linux-config"
@ -10,46 +8,26 @@ link_to_lc () {
echo "Linking $1 from $3 to $2." echo "Linking $1 from $3 to $2."
sys_dir="$2" sys_dir="$2"
config_dir="$3" config_dir="$3"
items=()
case "$1" in case "$1" in
# }}} vars #
# files {{{ #
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) 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 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 "files" "$HOME" "$lc_dir/dotfiles"
link_to_lc "dirs" "$HOME/.config" "$lc_dir/configs" link_to_lc "dirs" "$HOME/.config" "$lc_dir/configs"
link_to_lc "dirs" "$HOME/.themes" "$lc_dir/gtk/themes" link_to_lc "dirs" "$HOME/.themes" "$lc_dir/gtk/themes"
# }}} run #
# setup nvim config {{{ # # setup nvim config {{{ #
# nvim_file="/home/kevin/lc-test/init.vim" # nvim_file="/home/kevin/lc-test/init.vim"

4
txt/key_dirs.txt

@ -1,7 +1,7 @@
# sys {{{ * # sys {{{ *
bg /home/kevin/Pictures/Backgrounds bg /home/kevin/Pictures/Backgrounds
cn /home/kevin/.config
co /home/kevin/.config
lc /home/kevin/linux-config/ lc /home/kevin/linux-config/
d /home/kevin/Downloads d /home/kevin/Downloads
D /home/kevin/Documents D /home/kevin/Documents
@ -14,7 +14,7 @@ o /
# cdn {{{ * # cdn {{{ *
co /home/kevin/coding
cn /home/kevin/coding
j /home/kevin/Documents/journal j /home/kevin/Documents/journal
ib /home/kevin/linux-config/configs/i3blocks-scripts ib /home/kevin/linux-config/configs/i3blocks-scripts
ra /home/kevin/linux-config/configs/ranger ra /home/kevin/linux-config/configs/ranger

1
txt/pacman-pkgs/aur-pkgs.txt

@ -3,4 +3,5 @@ texlive-localmanager-git
gscreenshot gscreenshot
rxvt-unicode-pixbuf rxvt-unicode-pixbuf
Hack NF Hack NF
the_silver_searcher
trizen trizen
Loading…
Cancel
Save