From 147512b83552a097f770db85def0d9d446420d1b Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Fri, 15 Sep 2017 11:30:20 -0400 Subject: Rename zsh scripts .zsh --- import.sh | 23 ----------------------- import.zsh | 21 +++++++++++++++++++++ install.sh | 28 ++++++++++++++-------------- link.sh | 39 --------------------------------------- link.zsh | 37 +++++++++++++++++++++++++++++++++++++ prune.sh | 10 ---------- prune.zsh | 9 +++++++++ 7 files changed, 81 insertions(+), 86 deletions(-) delete mode 100755 import.sh create mode 100755 import.zsh delete mode 100755 link.sh create mode 100755 link.zsh delete mode 100755 prune.sh create mode 100755 prune.zsh diff --git a/import.sh b/import.sh deleted file mode 100755 index d7c3b072..00000000 --- a/import.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env zsh - -# Import a file from ~ and replace it with a symlink. - -set -o errexit -o nounset -o pipefail - -error() { - echo "$1" - exit 1 -} - -[ -z "$1" ] && error 'no path' - -source_path="$HOME/$1" -dest_path="$PWD/home/$1" - -[ -f "$dest_path" ] && error "$dest_path already exists" -[ -f "$source_path" ] || error "$source_path does not exist" - -mkdir -p "$(dirname "$dest_path")" -mv "$source_path" "$dest_path" -ln -s "$dest_path" "$source_path" -echo "link '$1'" >> link.sh diff --git a/import.zsh b/import.zsh new file mode 100755 index 00000000..6b69865a --- /dev/null +++ b/import.zsh @@ -0,0 +1,21 @@ +#!/usr/bin/env zsh +set -o errexit -o nounset -o pipefail + +# Import file from ~ and replace it with a symlink. + +fail() { + echo "$1" + exit 1 +} + +[ -z "$1" ] && fail 'no path' + +source_path="$HOME/$1" +dest_path="$PWD/home/$1" + +[ -f "$dest_path" ] && fail "$dest_path exists" + +mkdir -p "$(dirname "$dest_path")" +mv "$source_path" "$dest_path" +ln -s "$dest_path" "$source_path" +echo "link '$1'" >> link.zsh diff --git a/install.sh b/install.sh index 0684b053..2e159f5a 100755 --- a/install.sh +++ b/install.sh @@ -3,26 +3,26 @@ set -eu common='gdb git gnupg htop sl the_silver_searcher tree' +homebrew=https://raw.githubusercontent.com/Homebrew/install/master/install macos() { - homebrew=https://raw.githubusercontent.com/Homebrew/install/master/install - xcode-select --install || true - [ ! -f /usr/local/bin/brew ] && ruby -e "`curl -fsSL $homebrew`" - brew install $common - brew install ddate neovim/neovim/neovim openssh + xcode-select --install || true + [ ! -f /usr/local/bin/brew ] && ruby -e "`curl -fsSL $homebrew`" + brew install $common + brew install ddate neovim/neovim/neovim openssh } freebsd() { - pkg install $common - pkg install curl ddate neovim sudo zsh + pkg install $common + pkg install curl ddate neovim sudo zsh } arch() { - pacman -Sy - pacman -S --needed base-devel - pacman -S --needed $common - pacman -S --needed neovim openssh zsh + pacman -Sy + pacman -S --needed base-devel + pacman -S --needed $common + pacman -S --needed neovim openssh zsh } -[ "$(uname)" = 'Darwin' ] && macos && exit -[ -f /usr/local/sbin/pkg ] && freebsd && exit -[ -f /usr/bin/pacman ] && arch && exit +[ "$(uname)" = 'Darwin' ] && macos +[ -f /usr/local/sbin/pkg ] && freebsd +[ -f /usr/bin/pacman ] && arch diff --git a/link.sh b/link.sh deleted file mode 100755 index e8daa38d..00000000 --- a/link.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env zsh - -# Create symlines in ~ for files in curtis. - -set -o errexit -o nounset -o pipefail - -error() { - echo "$1" - exit 1 -} - -link() { - local source_path="$PWD/home/$1" - local dest_path="$HOME/$1" - - [ -h "$dest_path" ] && return - [ -e "$dest_path" ] && error "$dest_path exists" - - mkdir -p "$(dirname "$dest_path")" - ln -s "$source_path" "$dest_path" - echo "$1" -} - -link '.bin/sup' -link '.bin/tup' -link '.bin/up' -link '.config/git/config' -link '.config/git/ignore' -link '.config/htop/htoprc' -link '.config/nvim/colors/trivial.vim' -link '.config/nvim/init.vim' -link '.config/nvim/syntax/nasm.vim' -link '.gdbinit' -link '.gnupg/gpg-agent.conf' -link '.hushlogin' -link '.inputrc' -link '.psqlrc' -link '.ssh/config' -link '.zshrc' diff --git a/link.zsh b/link.zsh new file mode 100755 index 00000000..13bb175b --- /dev/null +++ b/link.zsh @@ -0,0 +1,37 @@ +#!/usr/bin/env zsh +set -o errexit -o nounset -o pipefail + +# Create symbolic links in ~. + +fail() { + echo "$1" + exit 1 +} + +link() { + local source_path="$PWD/home/$1" + local dest_path="$HOME/$1" + + [ -L "$dest_path" ] && return + + mkdir -p "$(dirname "$dest_path")" + ln -s "$source_path" "$dest_path" + echo "$1" +} + +link '.bin/sup' +link '.bin/tup' +link '.bin/up' +link '.config/git/config' +link '.config/git/ignore' +link '.config/htop/htoprc' +link '.config/nvim/colors/trivial.vim' +link '.config/nvim/init.vim' +link '.config/nvim/syntax/nasm.vim' +link '.gdbinit' +link '.gnupg/gpg-agent.conf' +link '.hushlogin' +link '.inputrc' +link '.psqlrc' +link '.ssh/config' +link '.zshrc' diff --git a/prune.sh b/prune.sh deleted file mode 100755 index 09ed8d35..00000000 --- a/prune.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env zsh - -# Remove symbolic links in ~ to files that no longer exist. - -set -o errexit -o nounset -o pipefail - -find -L ~ -type l -lname "$PWD/*" | while read link; do - rm "$link" - echo "$link" -done diff --git a/prune.zsh b/prune.zsh new file mode 100755 index 00000000..26dd27cc --- /dev/null +++ b/prune.zsh @@ -0,0 +1,9 @@ +#!/usr/bin/env zsh +set -o errexit -o nounset -o pipefail + +# Remove broken symbolic links in ~. + +find -L ~ -type l -lname "$PWD/*" | while read link; do + rm "$link" + echo "$link" +done -- cgit 1.4.1