.sh

Multi-shell dotfiles manager
Log | Files | Refs | README | LICENSE

commit 8b89e4e2cafadc42d15abd13a6bcccbc640097e0
parent 55c45e454fd5f3c3e1606ef20ac0cca7e157fe2e
Author: Byron Torres <b@torresjrjr.com>
Date:   Tue, 23 Feb 2021 01:12:25 +0000

Append $DOTSHELL/bin to $PATH, Rewrite usage

Diffstat:
Abin/dotshell | 48++++++++++++++++++++++++++++++++++++++++++++++++
Dbin/sync | 47-----------------------------------------------
Msh/.profile | 3++-
3 files changed, 50 insertions(+), 48 deletions(-)

diff --git a/bin/dotshell b/bin/dotshell @@ -0,0 +1,48 @@ +#!/bin/sh +# sync +# Creates symbolic links from $HOME to .profile and .zshenv + +usage() { + printf 'usage: dotshell <shell>... + +Synchronises the necessary dotfiles of <shell> in $DOTSHELL at $HOME. +' +} + +test -z "$1" || test "$1" = "-h" || test "$1" = "--help" && { + usage ; exit 1 +} + +test -z "$DOTSHELL" && { + echo "Warning! \$DOTSHELL was not set. Setting to default." + DOTSHELL="$HOME/.sh" +} +echo "DOTSHELL=$DOTSHELL" + +sync_dotfile() { + test "$1" = "$(readlink "$2")" && rm -v "$2" + test -e "$2" && { + printf '\e[33mWarning:\e[0m \e[1m%s\e[0m is not link to \e[1m%s\e[0m, skipping\n' \ + "$2" "$1" 1>&2 + return + } + ln -sv "$1" "$2" +} + +for shell in $@ +do + case $shell in + sh) + sync_dotfile "$DOTSHELL/sh/.profile" "$HOME/.profile" + ;; + bash) + sync_dotfile "$DOTSHELL/sh/.profile" "$HOME/.profile" + sync_dotfile "$DOTSHELL/bash/.bashrc" "$HOME/.bashrc" + ;; + zsh) + sync_dotfile "$DOTSHELL/zsh/.zshenv" "$HOME/.zshenv" + ;; + *) + echo "shell '$shell' unrecognised" + esac +done diff --git a/bin/sync b/bin/sync @@ -1,47 +0,0 @@ -#!/bin/sh -# sync -# Creates symbolic links from $HOME to .profile and .zshenv - -usage() { - printf "\ -Usage: sync SHELL... - -Creates symbolic links from ~ to corresponding shell dotfiles. -" -} - -test -z "$1" || test "$1" = "-h" && { usage ; exit 1 ;} - -test -z "$DOTSHELL" && { - echo "Warning! \$DOTSHELL was not set. Setting to default." - DOTSHELL="$HOME/.sh" -} -echo "DOTSHELL=$DOTSHELL" - -sync_dotfile() { - test "$1" = "$(readlink "$2")" && rm -v "$2" - test -e "$2" && { - printf '\e[33mWarning:\e[0m \e[1m%s\e[0m is not link to \e[1m%s\e[0m, skipping\n' \ - "$2" "$1" 1>&2 - return - } - ln -sv "$1" "$2" -} - -for shell in $@ -do - case $shell in - sh) - sync_dotfile "$DOTSHELL/sh/.profile" "$HOME/.profile" - ;; - bash) - sync_dotfile "$DOTSHELL/sh/.profile" "$HOME/.profile" - sync_dotfile "$DOTSHELL/bash/.bashrc" "$HOME/.bashrc" - ;; - zsh) - sync_dotfile "$DOTSHELL/zsh/.zshenv" "$HOME/.zshenv" - ;; - *) - echo "shell '$shell' unrecognised" - esac -done diff --git a/sh/.profile b/sh/.profile @@ -10,8 +10,9 @@ export DOTSHELL="$HOME/.sh" # rcfile for interactive-only POSIX sh. See sh(1). export ENV="$DOTSHELL/sh/.shrc" -export INPUTRC="$DOTSHELL/misc/.inputrc" export PATH="$PATH:$HOME/bin" +export PATH="$PATH:$DOTSHELL/bin" +export INPUTRC="$DOTSHELL/misc/.inputrc" # system defaults export XDG_CONFIG_HOME="$HOME/.config"