From 6e0acb759f397f3695a501cbd34c1fc87763c5ab Mon Sep 17 00:00:00 2001 From: "flyingscorpio@pinebook-pro" Date: Tue, 14 Apr 2020 10:30:27 +0200 Subject: [PATCH] Factoring --- installation_scripts/vim.sh | 18 ++++------------ main_install.sh | 41 +++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 34 deletions(-) diff --git a/installation_scripts/vim.sh b/installation_scripts/vim.sh index 9cdeb29..a3f87ed 100644 --- a/installation_scripts/vim.sh +++ b/installation_scripts/vim.sh @@ -10,17 +10,7 @@ fi # Add .vimrc {{{ echo "Adding .vimrc..." -if [ ! -L ~/.vimrc ]; then - if [ "$OVERWRITE" = 'true' ]; then - rm ~/.vimrc 2> /dev/null - fi - if ln -rs "$BASE_DIR"/dotfiles/vim/vimrc ~/.vimrc 2> /dev/null; then - echo "${ORANGE}.vimrc symlink created.${NC}" - fi -else - echo "${GREEN}.vimrc was already a symlink." - echo "Nothing changed.${NC}" -fi +make_symlink ~/.vimrc "$BASE_DIR"/dotfiles/vim/vimrc # }}} @@ -31,7 +21,7 @@ mkdir -p ~/.vim/colors color_files=$(ls "$BASE_DIR"/dotfiles/vim/colors) for color_file in $color_files; do - ln -rs "$BASE_DIR"/dotfiles/vim/colors/"$color_file" ~/.vim/colors/ 2> /dev/null + make_symlink ~/.vim/colors/"$color_file" "$BASE_DIR"/dotfiles/vim/colors/"$color_file" done # }}} @@ -163,8 +153,8 @@ fi echo "Adding YouCompleteMe extra_conf files..." -ln -rs "$BASE_DIR"/dotfiles/vim/ycm_extra_conf.py ~/.ycm_extra_conf.py 2> /dev/null -ln -rs "$BASE_DIR"/dotfiles/vim/global_extra_conf.py ~/.global_extra_conf.py 2> /dev/null +make_symlink ~/.ycm_extra_conf.py "$BASE_DIR"/dotfiles/vim/ycm_extra_conf.py +make_symlink ~/.global_extra_conf.py "$BASE_DIR"/dotfiles/vim/global_extra_conf.py # }}} diff --git a/main_install.sh b/main_install.sh index f870ea7..8899ac1 100755 --- a/main_install.sh +++ b/main_install.sh @@ -22,6 +22,26 @@ export BASE_DIR GITHUB_DOTFILES=~/github_dotfiles export GITHUB_DOTFILES +make_symlink() { + + link=$1 + target=$2 + + if [ "$link" -ef "$target" ]; then + echo "${GREEN}$link points to the right location." + echo "Nothing changed.${NC}" + else + if [ "$OVERWRITE" = 'true' ]; then + rm "$link" 2> /dev/null + fi + if ln -rs "$target" "$link"; then + echo "${ORANGE}$link symlink created${NC}" + fi + fi + +} +export -f make_symlink + separator() { exit_status=$? if [ $exit_status -eq 0 ]; then @@ -199,25 +219,6 @@ install_scripts() { # {{{ } # }}} -make_symlink() { # {{{ - - link=$1 - target=$2 - - if [ "$link" -ef "$target" ]; then - echo "${GREEN}$link points to the right location." - echo "Nothing changed.${NC}" - else - if [ "$OVERWRITE" = 'true' ]; then - rm "$link" 2> /dev/null - fi - if ln -rs "$target" "$link"; then - echo "${ORANGE}$link symlink created${NC}" - fi - fi - -} # }}} - markdown_mimetype() { # {{{ # Add MIME type for reading .md files in Firefox (need to add extension too) @@ -312,7 +313,7 @@ setup_vim() { # {{{ # setup_bash_files # setup_bash_git_prompt # install_rust -# setup_vim +setup_vim # setup_sddm # setup_i3 # markdown_mimetype