commit d0dbb83385a50dfdbb5e1715185599974a2200c8
parent f0b18fea7da92728f90fa2be6fd4a509563edc93
Author: Alex Balgavy <a.balgavy@gmail.com>
Date: Tue, 8 Jan 2019 19:32:02 +0100
Created separate conf script to aid dotfiles
Install now runs the conf script, the conf script is used to manage all
of the dotfiles.
Former-commit-id: 7d0f6f81c3f4c67b5a86c94577dc1d1084a174c4
Diffstat:
12 files changed, 146 insertions(+), 96 deletions(-)
diff --git a/bin/.bin b/bin/.bin
@@ -0,0 +1 @@
+/Users/alex/.dotfiles/bin+
\ No newline at end of file
diff --git a/bin/conf b/bin/conf
@@ -0,0 +1,120 @@
+#!/usr/bin/env bash
+# vim: foldmethod=marker:foldlevel=0
+
+# Functions {{{
+lncommand() {
+ if [ -e "$1" ]; then
+ if [ -e "$2" ]; then
+ echo "-- Backing up original $2"
+ mv -iv "$2" "$2-orig"
+ fi
+ ln -snfv $(pwd)/"$1" "$2";
+ fi
+}
+stow_files() {
+ if [ $# -gt 0 ]; then
+ for f in "$@"; do
+ case "${f##./}" in
+ "bin")
+ lncommand "bin" "$HOME/.bin"
+ if command -v mpv &> /dev/null; then
+ mkdir -p $HOME/.config/mpv
+ lncommand ".bin/visualizer.lua" "$HOME/.config/mpv/visualizer.lua"
+ fi
+ ;;
+ "ctags")
+ lncommand "ctags/ctags" "$HOME/.ctags"
+ ;;
+ "gdb")
+ lncommand "gdb/gdbinit" "$HOME/.gdbinit"
+ ;;
+
+ "git")
+ lncommand "git/gitconfig" "$HOME/.gitconfig"
+ if [ -d git/git_template ]; then
+ conf_check git config --global init.templatedir "$CONF_DIR"/git/git_template
+ fi
+ ;;
+ "iterm2")
+ lncommand "iterm2" "$HOME/.iterm2"
+ ;;
+ "oh-my-zsh")
+ lncommand "oh-my-zsh" "$HOME/.oh-my-zsh"
+ ;;
+ "radio")
+ lncommand "radio/radio-config" "$HOME/.radio-config"
+ ;;
+
+ "shell")
+ for i in $(ls shell); do
+ lncommand shell/"$i" $HOME/."$i"
+ done
+ ;;
+ "vim")
+ lncommand vim/init.vimrc $HOME/.vimrc # vimrc points directly to other vim configs
+ lncommand vim/idea.vimrc $HOME/.ideavimrc # ideavimrc has to be separate
+ ;;
+ esac
+
+ done
+ else
+ echo "Config files:"
+ echo "bin various executable scripts"
+ echo "ctags language definitions for ctags"
+ echo "gdb gdb dashboard and the like"
+ echo "git git config files and hooks"
+ echo "oh-my-zsh the whole oh-my-zsh config directory"
+ echo "radio radio metadata for the internet radio script"
+ echo "shell various configs related to shells"
+ echo "vim vim configuration files"
+ fi
+}
+conf_check() {
+ if [ -z "$CONF_DIR" ]; then
+ echo '$CONF_DIR not set.'
+ else
+ "$@"
+ fi
+}
+#}}}
+
+if [ $# -gt 0 ]; then
+ if [ "$1" = 'cd' ]; then
+ conf_check cd "$CONF_DIR"
+ elif [ "$1" = 'rc' ]; then
+ if [[ $SHELL = *"zsh"* ]]; then
+ vim "$HOME"/.zshrc
+ elif [[ $SHELL = *"bash"* ]]; then
+ vim "$HOME"/.bashrc
+ else
+ echo "Shell profile not supported yet."
+ echo "Feel free to ask me to add support, or you can do it yourself."
+ fi
+ elif [ "$1" = 'common' ]; then
+ vim "$HOME"/.commonprofile
+ elif [ "$1" = 'reload' ]; then
+ if [[ $SHELL = *"zsh"* ]]; then
+ START_TIME=$SECONDS
+ source "$HOME"/.zshrc
+ echo "Reloaded zsh config ($(( SECONDS-START_TIME )) sec)."
+ elif [[ $SHELL = *"bash"* ]]; then
+ START_TIME=$SECONDS
+ source "$HOME"/.bashrc
+ echo "Reloaded bash config ($(( SECONDS-START_TIME )) sec)."
+ fi
+ elif [ "$1" = 'get' ]; then
+ conf_check echo "$CONF_DIR"
+ elif [ "$1" = 'stow' ]; then
+ stow_files "${@:2}"
+ else
+ conf_check $(command -v git) --git-dir="$CONF_DIR"/.git --work-tree "$CONF_DIR" "$@"
+ fi
+else
+ echo "Usage:"
+ echo "conf cd Go to conf directory"
+ echo "conf rc Edit shell-specific profile (zshrc, bashrc, etc.)"
+ echo "conf common Edit common profile"
+ echo "conf reload Reload configuration files"
+ echo "conf get Print path to configuration directory"
+ echo "conf [git command] Run git command in conf directory"
+fi
diff --git a/other-scripts/visualizer.lua b/bin/visualizer.lua
diff --git a/other-scripts/vwtags.py b/bin/vwtags.py
diff --git a/other-scripts/ctags b/ctags/ctags
diff --git a/other-scripts/gdbinit b/gdb/gdbinit
diff --git a/git/gitconfig b/git/gitconfig
@@ -51,3 +51,5 @@
tool = vimdiff
[core]
autocrlf = input
+[init]
+ templatedir = /Users/alex/.dotfiles/git/git_template
diff --git a/install.sh b/install.sh
@@ -1,11 +1,18 @@
#!/bin/bash
+# vim: foldmethod=marker:foldlevel=0
+# Preliminary checks {{{
# Check if this directory was cloned properly
if [ $(pwd) != "$HOME/.dotfiles" ]; then
echo "Please clone this directory as $HOME/.dotfiles."
exit 1
fi
+if ! [ -f "./install.sh" ]; then
+ echo "Please cd into $HOME/.dotfiles before running the script."
+ exit 1
+fi
+
# Check if the OS is supported
if [[ $(uname -s) == "Darwin" ]]; then
echo "Setting up your Mac..."
@@ -22,57 +29,15 @@ else
exit 1
fi
-export CONF_DIR="$HOME/.dotfiles"
-
-lncommand() { ln -snfv $(pwd)/"$1" "$2"; }
-
-# Back up previous files
-if [ -d "$HOME/.vim" ]; then
- mv "$HOME/.vim" "$HOME/.vim.orig"
-fi
-if [ -f "$HOME/.vimrc" ]; then
- mv "$HOME/.vimrc" "$HOME/.vimrc.orig"
-fi
-
-
-# Link stuff conditionally in case of a sparse checkout
-if [ -d ".bin" ]; then
- lncommand "bin" "$HOME/.bin"
-fi
-
-if [ -d "oh-my-zsh" ]; then
- lncommand "oh-my-zsh" "$HOME/.oh-my-zsh"
-fi
+#}}}
+export CONF_DIR="$HOME/.dotfiles"
+bin/conf stow $(find . ! -iwholename '*.git*' -type d -d 1)
-if [ -d "shell" ]; then
- for i in $(ls shell); do
- lncommand shell/"$i" $HOME/."$i"
- done
-fi
-
-if [ -d "git" ]; then
- lncommand git/gitconfig $HOME/.gitconfig
- git config --global init.templatedir $CONF_DIR/git/git_template
-fi
-
-if [ -f "other-scripts/gdbinit" ]; then
- lncommand "other-scripts/gdbinit" "$HOME/.gdbinit"
-fi
-if [ -f "other-scripts/visualizer.lua" ]; then
- mkdir -p $HOME/.config/mpv
- lncommand "other-scripts/visualizer.lua" "$HOME/.config/mpv/visualizer.lua"
-fi
-
-if [ -f "other-scripts/radio-config" ]; then
- lncommand "other-scripts/radio-config" "$HOME/.radio-config"
-fi
-
-if [ -d "vim" ]; then
- # Link vimrc (which points directly to other vim configs)
- lncommand vim/init.vimrc $HOME/.vimrc
-
- # Link ideavimrc, has to be separate
- lncommand vim/idea.vimrc $HOME/.ideavimrc
-fi
+echo "Dotfiles installed."
+bin/conf reload
+echo "Run `conf` for more help."
+echo "Don't forget to create a ~/.secret_env_variables with:"
+echo '- $DISCOGS_API_TOKEN'
+echo '- $HOMEBREW_GITHUB_API_TOKEN'
diff --git a/iterm2/com.googlecode.iterm2.plist b/iterm2/com.googlecode.iterm2.plist
@@ -462,11 +462,11 @@
<key>NSWindow Frame SessionsPreferences</key>
<string>269 126 606 469 0 0 1440 900 </string>
<key>NSWindow Frame SharedPreferences</key>
- <string>44 150 918 494 0 0 1440 900 </string>
+ <string>306 398 796 486 0 0 1440 900 </string>
<key>NSWindow Frame iTerm Window 0</key>
- <string>720 0 717 900 0 0 1440 900 </string>
+ <string>0 0 1424 881 0 0 1440 900 </string>
<key>NSWindow Frame iTerm Window 1</key>
- <string>330 492 850 384 0 0 1440 900 </string>
+ <string>720 516 850 384 0 0 1440 900 </string>
<key>NSWindow Frame iTerm Window 2</key>
<string>1034 65 376 324 0 0 1440 900 </string>
<key>NSWindow Frame iTerm Window 3</key>
@@ -3757,7 +3757,7 @@
</dict>
</dict>
<key>PrefsCustomFolder</key>
- <string>/Users/alex/.dotfiles/iterm2</string>
+ <string>/Users/alex/.iterm2</string>
<key>Print In Black And White</key>
<true/>
<key>SUAutomaticallyUpdate</key>
@@ -3771,7 +3771,7 @@
<key>SUHasLaunchedBefore</key>
<true/>
<key>SULastCheckTime</key>
- <date>2018-12-07T18:58:15Z</date>
+ <date>2019-01-07T13:25:07Z</date>
<key>SUSendProfileInfo</key>
<false/>
<key>ShowFullScreenTabBar</key>
diff --git a/other-scripts/radio-config b/radio/radio-config
diff --git a/shell/commonprofile b/shell/commonprofile
@@ -57,45 +57,6 @@ fi
# }}}
-# Set up conf command {{{
-conf() {
- if [ $# -gt 0 ]; then
- if [ "$1" = 'cd' ]; then
- cd ~/.dotfiles || return;
- elif [ "$1" = 'rc' ]; then
- if [[ $SHELL = *"zsh"* ]]; then
- vim ~/.zshrc
- elif [[ $SHELL = *"bash"* ]]; then
- vim ~/.bashrc
- fi
- elif [ "$1" = 'common' ]; then
- vim ~/.commonprofile
- elif [ "$1" = 'reload' ]; then
- if [[ $SHELL = *"zsh"* ]]; then
- START_TIME=$SECONDS
- source ~/.zshrc
- echo "Reloaded zsh config ($(( $SECONDS-$START_TIME )) sec)."
- elif [[ $SHELL = *"bash"* ]]; then
- START_TIME=$SECONDS
- source ~/.bashrc
- echo "Reloaded bash config ($(( $SECONDS-$START_TIME )) sec)."
- fi
- elif [ "$1" = 'get' ]; then
- echo "$CONF_DIR"
- else
- $(command -v git) --git-dir="$HOME"/.dotfiles/.git --work-tree "$HOME"/.dotfiles/ "$@"
- fi
- else
- echo "Usage:"
- echo "conf cd Go to conf directory"
- echo "conf rc Edit shell-specific profile (zshrc, bashrc, etc.)"
- echo "conf common Edit common profile"
- echo "conf reload Reload configuration files"
- echo "conf get Print path to configuration directory"
- echo "conf [git command] Run git command in conf directory"
- fi
-}
-# }}}
# Aliases (simple) {{{
alias c="clear"
diff --git a/vim/pluginconf.vimrc b/vim/pluginconf.vimrc
@@ -6,7 +6,7 @@ let g:tagbar_type_vimwiki = {
\ , 'sro':'&&&'
\ , 'kind2scope':{'h':'header'}
\ , 'sort':0
- \ , 'ctagsbin':'$CONF_DIR/other-scripts/vwtags.py'
+ \ , 'ctagsbin':'$CONF_DIR/bin/vwtags.py'
\ , 'ctagsargs': 'default'
\ }