dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 36c8d3464b6ad92bd4acd8876705f818894543fd
parent 77c80b256bcf0684865dc53830574fba9226ca02
Author: Alex Balgavy <a.balgavy@gmail.com>
Date:   Sun,  3 Nov 2019 13:23:25 -0500

conf: edit map file, don't parse unless needed

Former-commit-id: 66e5b0c88d465f909715021f555d4d3da44ca941
Diffstat:
Ddotmap.conf | 56--------------------------------------------------------
Mscripts/conf | 22++++++++++++++++++++--
2 files changed, 20 insertions(+), 58 deletions(-)

diff --git a/dotmap.conf b/dotmap.conf @@ -1,56 +0,0 @@ -# Custom stuff I write -bin: ~/.bin -scripts: ~/.scripts - -# Utilities -compton: ~/.config/compton -ctags.d: ~/.ctags.d -gdb: -- gdbinit: ~/.gdbinit -git: -- gitconfig: ~/.gitconfig -i3: ~/.config/i3 -irssi: ~/.config/irssi -karabiner: ~/.config/karabiner -lf: ~/.config/lf -newsboat: ~/.newsboat -oh-my-zsh: ~/.oh-my-zsh -polybar: ~/.config/polybar -radio: -- radio-config: ~/.radio-config -ranger: ~/.config/ranger -rtv: ~/.config/rtv -screen: -- screenrc: ~/.screenrc -tmux: -- tmux.conf: ~/.tmux.conf -ghci: ~/.ghci - -# X server -xinitrc: ~/.xinitrc -xprofile: ~/.xprofile -Xresources: ~/.Xresources - -# Emacs config -emacs: -- emacs.d: ~/.emacs.d -- emacs: ~/emacs - -# All shell config -shell: -- aliases: ~/.aliases -- functions: ~/.functions -- secret_env_variables: ~/.secret_env_variables -- zprofile: ~/.zprfile -- zshrc: ~/.zshrc - -# Vim config -vim: -- after: ~/.vim/after -- autoload: ~/.vim/autoload -- colors: ~/.vim/colors -- compiler: ~/.vim/compiler -- ftdetect: ~/.vim/ftdetect -- plugin: ~/.vim/plugin -- ultisnips: ~/.vim/ultisnips -- vimrc: ~/.vimrc diff --git a/scripts/conf b/scripts/conf @@ -4,6 +4,9 @@ # Set the dir for your dotfiles, mine comes from the environment DOTFILES="${DOTFILES}" +# Set the name of the mapfile, located in the root folder of your dotfiles +mapfile="dot.map" + die() { echo "$1" >&2 exit 1 @@ -114,7 +117,6 @@ list_mappings() { } declare -A mappings -parse_mapfile "./dot.map" PARAMS="" link_mode=0 @@ -122,6 +124,7 @@ unlink_mode=0 while (( "$#" )); do case "$1" in -l|--list) + parse_mapfile "./${mapfile}" list_mappings exit 0 ;; @@ -131,7 +134,8 @@ while (( "$#" )); do echo "conf [options] (link|unlink) [entry1 [entry2...]]" echo echo "Options:" - echo " -l, --list only list maps" + echo " -l, --list only list maps" + echo " -e, --edit edit map file" echo echo "link [entry1 [entry2...]] Link entries according to the map file." echo " With no arguments, links all entries." @@ -140,12 +144,23 @@ while (( "$#" )); do echo " With no arguments, unlinks all entries." exit 0 ;; + + -e|--edit) + # $EDITOR is an environment variable + # shellcheck disable=SC2154 + "${EDITOR}" "${DOTFILES}/${mapfile}" + exit 0 + ;; + --) # end arg parsing shift break ;; -*) # unsupported flags echo "Unsupported flag $1" >&2 + + # Don't want the command to expand so + # shellcheck disable=SC2016 echo 'Run `conf -h` to show usage.' exit 1 ;; @@ -170,8 +185,11 @@ case "$1" in ;; esac +# Don't want the command to expand so +# shellcheck disable=SC2016 [ "${link_mode}" -eq 0 ] && [ "${unlink_mode}" -eq 0 ] && die 'Arguments required, run `conf -h` to show usage.' +parse_mapfile "./${mapfile}" if [ "${link_mode}" -eq 1 ]; then if [ $# -eq 0 ]; then read -srp "Link all dotfiles?" -n 1 -s conf