From a86c2ddece8fde8a42f1e6031b189d1865b9b211 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Wed, 18 Jul 2018 19:53:53 -0400 Subject: [PATCH] Prefer stow over hand-rolled solution After discovering GNU stow on Nix IRC, refactored install and setup scripts to consume it. Code is vastly simplified as a result. --- configs/linux/{ => xinit}/.xinitrc | 0 configs/os_x/{ => slate}/.slate.js | 0 configs/setup | 44 +++-------------------------- configs/shared/{ => ctags}/.ctags | 0 configs/shared/ghci | 13 --------- configs/shared/{ => git}/.gitconfig | 0 configs/shared/{ => git}/.gitignore | 0 configs/shared/haskell/.ghci | 32 +++++++++++++++++++++ configs/shared/{ => zsh}/.zshrc | 3 ++ install.sh | 6 ++-- 10 files changed, 42 insertions(+), 56 deletions(-) rename configs/linux/{ => xinit}/.xinitrc (100%) rename configs/os_x/{ => slate}/.slate.js (100%) rename configs/shared/{ => ctags}/.ctags (100%) delete mode 100644 configs/shared/ghci rename configs/shared/{ => git}/.gitconfig (100%) rename configs/shared/{ => git}/.gitignore (100%) create mode 100644 configs/shared/haskell/.ghci rename configs/shared/{ => zsh}/.zshrc (74%) diff --git a/configs/linux/.xinitrc b/configs/linux/xinit/.xinitrc similarity index 100% rename from configs/linux/.xinitrc rename to configs/linux/xinit/.xinitrc diff --git a/configs/os_x/.slate.js b/configs/os_x/slate/.slate.js similarity index 100% rename from configs/os_x/.slate.js rename to configs/os_x/slate/.slate.js diff --git a/configs/setup b/configs/setup index e81b49442..7b7a81490 100755 --- a/configs/setup +++ b/configs/setup @@ -1,47 +1,11 @@ #!/usr/bin/env bash -dotfiles_path="${HOME}/dotfiles" -configs_dir="${dotfiles_path}/configs" -shared_configs="${configs_dir}/shared" +configs="$HOME/dotfiles/configs" if [[ $(uname) == 'Darwin' ]]; then - os_specific_configs="${configs_dir}/os_x" + (cd "$configs/os_x" && stow --target="$HOME" *) elif [[ $(uname) == 'Linux' ]]; then - os_specific_configs="${configs_dir}/linux" + (cd "$configs/linux" && stow --target="$HOME" *) fi - -function symlink_configs () { - configs_dir=$1 - - for cf in $(find $configs_dir -type f -name ".*"); do - filename=$(grep -o "[^\/]+$" <<<$cf) - echo "$filename: " - - if [ -f "${HOME}/${filename}" ] && [ ! -L "${HOME}/${filename}" ]; then - echo -n "Backing up ${filename}... " && \ - mv "${HOME}/${filename}" "${HOME}/${filename}.bak" && \ - echo "Done." - fi - - if [ -L "${HOME}/${filename}" ]; then - if [ $(readlink "${HOME}/${filename}") = $cf ]; then - echo "Already properly symlinked to ${configs_dir}." - else - echo "Already symlinked but NOT to the proper location. Aborting..." - fi - else - echo -n "Symlinking to ${filename}... " && \ - ln -s $cf "${HOME}/${filename}" && \ - echo "Done." - fi - echo "" - done -} - - -# handle shared configs -symlink_configs $shared_configs - -# handle os-specific configs -symlink_configs $os_specific_configs +(cd "$configs/shared" && stow --target="$HOME" *) diff --git a/configs/shared/.ctags b/configs/shared/ctags/.ctags similarity index 100% rename from configs/shared/.ctags rename to configs/shared/ctags/.ctags diff --git a/configs/shared/ghci b/configs/shared/ghci deleted file mode 100644 index 844a89010..000000000 --- a/configs/shared/ghci +++ /dev/null @@ -1,13 +0,0 @@ --- Useful Typeclasses -import Control.Applicative -import Data.Monoid - --- Data Structures -import qualified Data.Map.Internal as Map - --- Lenses -import qualified Control.Lens as Lens -import qualified Control.Lens.Traversal as Lens - --- Friendly prompt -:set prompt "\ESC[34mλ> \ESC[m" diff --git a/configs/shared/.gitconfig b/configs/shared/git/.gitconfig similarity index 100% rename from configs/shared/.gitconfig rename to configs/shared/git/.gitconfig diff --git a/configs/shared/.gitignore b/configs/shared/git/.gitignore similarity index 100% rename from configs/shared/.gitignore rename to configs/shared/git/.gitignore diff --git a/configs/shared/haskell/.ghci b/configs/shared/haskell/.ghci new file mode 100644 index 000000000..995a5cec2 --- /dev/null +++ b/configs/shared/haskell/.ghci @@ -0,0 +1,32 @@ +-- Useful Typeclasses +import Control.Applicative +import Data.Monoid + +-- Data Structures +import qualified Data.Map.Internal as Map + +-- Lenses +import Control.Lens +import qualified Control.Lens as Lens +import qualified Control.Lens.Traversal as Lens + +-- Friendly prompt +:set prompt "\ESC[34mλ> \ESC[m" + +-- GHCi on Acid +:m - Prelude +:m + GOA +setLambdabotHome "/Users/wpcarro/Haskell/bin" +:def bs lambdabot "botsnack" +:def pl lambdabot "pl" +:def unpl lambdabot "unpl" +:def redo lambdabot "redo" +:def undo lambdabot "undo" +:def index lambdabot "index" +:def docs lambdabot "docs" +:def instances lambdabot "instances" +:def hoogle lambdabot "hoogle" +:def source lambdabot "fptools" +:def where lambdabot "where" +:def version lambdabot "version" +:def src lambdabot "src" diff --git a/configs/shared/.zshrc b/configs/shared/zsh/.zshrc similarity index 74% rename from configs/shared/.zshrc rename to configs/shared/zsh/.zshrc index f18ef365e..49452db76 100644 --- a/configs/shared/.zshrc +++ b/configs/shared/zsh/.zshrc @@ -3,6 +3,9 @@ export DOTFILES="${HOME}/dotfiles" export ZSH="${HOME}/.oh-my-zsh" export PATH="${PATH}:${HOME}/.local/bin" +# Put this here temporarily until we have a better place for it. +export FPP_EDITOR='emacsclient -n' + ZSH_THEME=refined plugins=(zsh-autosuggestions git git-extras github) diff --git a/install.sh b/install.sh index ed2b80fcf..d8233b3bf 100644 --- a/install.sh +++ b/install.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env zsh +#!/usr/bin/env bash -source "${DOTFILES}/configs/setup" -ln -s "${DOTFILES}/emacs.d" "${HOME}/.emacs.d" +source "$HOME/dotfiles/configs/setup" +ln -s "$DOTFILES/emacs.d" "$HOME/.emacs.d"