From 3a7a6d89708a62ca2efd8b36dd44fa30d461f23a Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Wed, 14 Mar 2018 21:53:11 -0400 Subject: Clean up home scripts, split again --- home.txt | 17 ----------------- home.zsh | 42 ------------------------------------------ link.zsh | 19 +++++++++++++++++++ prune.zsh | 7 +++++++ 4 files changed, 26 insertions(+), 59 deletions(-) delete mode 100644 home.txt delete mode 100755 home.zsh create mode 100755 link.zsh create mode 100755 prune.zsh diff --git a/home.txt b/home.txt deleted file mode 100644 index 4489872e..00000000 --- a/home.txt +++ /dev/null @@ -1,17 +0,0 @@ -.bin/sup -.bin/tup -.bin/up -.config/git/config -.config/git/ignore -.config/htop/htoprc -.config/nvim/colors/trivial.vim -.config/nvim/init.vim -.config/nvim/syntax/nasm.vim -.gdbinit -.gnupg/gpg-agent.conf -.hushlogin -.inputrc -.lldbinit -.psqlrc -.ssh/config -.zshrc diff --git a/home.zsh b/home.zsh deleted file mode 100755 index 8490a3b5..00000000 --- a/home.zsh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env zsh -set -o errexit -o nounset -o pipefail - -fail() { - echo "$@" - exit 1 -} - -link() { - local relPath srcPath dstPath - < home.txt while read relPath; do - srcPath="$PWD/home/$relPath" - dstPath="$HOME/$relPath" - [ -L "$dstPath" ] && continue - mkdir -p "$(dirname "$dstPath")" - ln -s "$srcPath" "$dstPath" - echo "$relPath" - done -} - -import() { - local relPath srcPath dstPath - relPath="$1" - srcPath="$HOME/$relPath" - dstPath="$PWD/home/$relPath" - [ -f "$dstPath" ] && fail "$dstPath exists" - mkdir -p "$(dirname "$dstPath")" - mv "$srcPath" "$dstPath" - ln -s "$dstPath" "$srcPath" - echo "$relPath" >> home.txt - sort -o home.txt home.txt -} - -prune() { - local linkPath - find -L ~ -type l -lname "$PWD/*" | while read linkPath; do - rm "$linkPath" - echo "$linkPath" - done -} - -$@ diff --git a/link.zsh b/link.zsh new file mode 100755 index 00000000..42c8d04c --- /dev/null +++ b/link.zsh @@ -0,0 +1,19 @@ +#!/usr/bin/env zsh +set -o errexit -o nounset -o pipefail + +if [ $# -eq 1 ]; then + linkPath="$1" + filePath="$PWD/home/${linkPath#$HOME/}" + [ ! -f "$filePath" ] + mkdir -p $(dirname "$filePath") + mv "$linkPath" "$filePath" +fi + +find home -type f | while read findPath; do + filePath="$PWD/$findPath" + linkPath="$HOME/${findPath#home/}" + [ -L "$linkPath" ] && continue + mkdir -p $(dirname "$linkPath") + ln -s "$filePath" "$linkPath" + echo "$linkPath" +done diff --git a/prune.zsh b/prune.zsh new file mode 100755 index 00000000..a0eb1f73 --- /dev/null +++ b/prune.zsh @@ -0,0 +1,7 @@ +#!/usr/bin/env zsh +set -o errexit -o nounset -o pipefail + +find -L ~ -type l -lname "$PWD/*" | while read linkPath; do + rm "$linkPath" + echo "$linkPath" +done -- cgit 1.4.1