Factoring

This commit is contained in:
flyingscorpio@pinebook-pro 2020-04-14 10:30:27 +02:00
parent 2bbc21ba38
commit 6e0acb759f
2 changed files with 25 additions and 34 deletions

View file

@ -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
# }}}

View file

@ -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