Swapped setup script for Makefile
This commit is contained in:
14
Makefile
Normal file
14
Makefile
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
all: softlinks
|
||||||
|
@echo "-----------------------------------------------------------"
|
||||||
|
@echo "Vim and environment"
|
||||||
|
@echo "-----------------------------------------------------------"
|
||||||
|
@echo "Open vim and type :PlugInstall to install extension manager"
|
||||||
|
|
||||||
|
softlinks: dependencies
|
||||||
|
@test -L ${HOME}/.vim || ln -s ${PWD}/.vim ${HOME}/.vim
|
||||||
|
@test -L ${HOME}/.vimrc || ln -s ${PWD}/.vimrc ${HOME}/.vimrc
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
@sudo apt install vim
|
||||||
|
|
||||||
|
|
||||||
13
README.md
13
README.md
@@ -5,8 +5,17 @@ Breaking this out of my dotfiles repo to try to get a handle on multiple configu
|
|||||||
I also want to finally have a `.vimrc` in which I understand each and every line. After years of collecting snips and
|
I also want to finally have a `.vimrc` in which I understand each and every line. After years of collecting snips and
|
||||||
scraps from other people's dotfiles, I want to make sure that I am aware of what my `.vimrc` is doing.
|
scraps from other people's dotfiles, I want to make sure that I am aware of what my `.vimrc` is doing.
|
||||||
|
|
||||||
This configuration is based heavily on the guide I found here: [Vim Zero](https://www.oliversherouse.com/2017/08/21/vim_zero.html)
|
This configuration is based heavily on the guide I found here: [Vim
|
||||||
which does exactly what I am aiming to do here: wipe the slate clean and start over.
|
Zero](https://www.oliversherouse.com/2017/08/21/vim_zero.html) which does exactly what I am aiming to do here: wipe the
|
||||||
|
slate clean and start over.
|
||||||
|
|
||||||
Whenever possible, I've noted the URL from which I found the setting or snippet. I try to insist that not everything
|
Whenever possible, I've noted the URL from which I found the setting or snippet. I try to insist that not everything
|
||||||
is self-explanatory.
|
is self-explanatory.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
The included Makefile will ensure vim is installed and the dotfiles get linked to your home directory.
|
||||||
|
|
||||||
|
make all
|
||||||
|
|
||||||
|
should do it.
|
||||||
|
|||||||
91
setup.sh
91
setup.sh
@@ -1,91 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
#===============================================================================
|
|
||||||
#
|
|
||||||
# FILE: setup.sh
|
|
||||||
# USAGE: ./setup.sh
|
|
||||||
# DESCRIPTION: after pulling/cloning dotfiles repo, this script will check/create
|
|
||||||
# symlinks for for dotfiles. It checks for the presence of installed
|
|
||||||
# software (i.e. won't symlink a dotfile for applications that aren't
|
|
||||||
# installed) and will remove links for applications that are no longer
|
|
||||||
# installed. Safe to run after every git pull
|
|
||||||
# OPTIONS:
|
|
||||||
# REQUIREMENTS: This script replies on the 'command' command. Basically, it will run
|
|
||||||
# `command -v <dotfile>` and if there is no output, it assumes the app
|
|
||||||
# isn't installed. So this won't work for apps that aren't in your $PATH
|
|
||||||
# reference: http://www.cyberciti.biz/faq/unix-linux-shell-find-out-posixcommand-exists-or-not/
|
|
||||||
# NOTES:
|
|
||||||
# AUTHOR: C Hawley
|
|
||||||
# CREATED: 2015-10
|
|
||||||
# REVISION: Tue 10 Oct 2017 04:37:37 PM EDT
|
|
||||||
#
|
|
||||||
#===============================================================================
|
|
||||||
|
|
||||||
set -o nounset # Treat unset variables as an error
|
|
||||||
|
|
||||||
# specify where your dotfiles live
|
|
||||||
dotfiledir="$HOME/dotfiles-vim"
|
|
||||||
|
|
||||||
# function to handle checking for existings links/files and updating
|
|
||||||
link() {
|
|
||||||
echo "symlinking ${1}"
|
|
||||||
# check for existing symlinks
|
|
||||||
if [ -h "${HOME}"/"${1}" ]; then
|
|
||||||
echo " - There's already a symlink named ${1}. Diff'ing."
|
|
||||||
# If there's an existing sylink, check if it's different than the dotfile
|
|
||||||
if [[ $(diff --brief "${HOME}"/"${1}" "${dotfiledir}"/"${1}") ]]; then
|
|
||||||
# If the links are different, ask if it should be replaced
|
|
||||||
echo " - Old link and new link are different:"
|
|
||||||
echo -n " - Replace existing symlink "${1}"? [Y/N] "
|
|
||||||
read replace
|
|
||||||
if [ "${replace}" = "Y" ] || [ "${replace}" = "y" ]; then
|
|
||||||
# If yes, unlink the old file and link the new one and exit
|
|
||||||
echo " - Unlinking old file and linking new file"
|
|
||||||
unlink "${HOME}"/"${1}"
|
|
||||||
ln -s "${dotfiledir}"/"${1}" "${HOME}"/"${1}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# If the link is the same, just exit function
|
|
||||||
echo " - Old link and new link are the same."
|
|
||||||
fi
|
|
||||||
# check for existing file/directory
|
|
||||||
elif [ -f "${HOME}"/"${1}" ] || [ -d "${HOME}"/"${1}" ]; then
|
|
||||||
echo " - There's already a file or directory named ${1}. Diff'ing."
|
|
||||||
if [[ $(diff --brief "${HOME}"/"${1}" "${dotfiledir}"/"${1}") ]]; then
|
|
||||||
echo " - Old file/dir and new link are different:"
|
|
||||||
echo -n " - Rename "${1}" and create new link? [Y/N] "
|
|
||||||
read replace
|
|
||||||
if [ "${replace}" = "Y" ] || [ "${replace}" = "y" ]; then
|
|
||||||
echo " - Renaming old file/dir and linking new file"
|
|
||||||
mv "${HOME}"/"${1}" "${HOME}"/"${1}"_original
|
|
||||||
ln -s "${dotfiledir}"/"${1}" "${HOME}"/"${1}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# If there is no existing file, create one and exit
|
|
||||||
echo " - Creating link for ${1}"
|
|
||||||
ln -s "${dotfiledir}"/"${1}" "${HOME}"/"${1}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
clear
|
|
||||||
|
|
||||||
echo "------------------------------------------"
|
|
||||||
echo " .vim/.vimrc repo setup script "
|
|
||||||
echo "------------------------------------------"
|
|
||||||
echo " Setting up symlinks "
|
|
||||||
echo "------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# link .vimrc
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
if [ $(command -v vim) ]; then
|
|
||||||
link .vim
|
|
||||||
link .vimrc
|
|
||||||
else
|
|
||||||
echo "... vim not installed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "------------------------------------------"
|
|
||||||
echo "Done. "
|
|
||||||
echo "------------------------------------------"
|
|
||||||
Reference in New Issue
Block a user