diff --git a/git/gitconfig b/git/gitconfig index 8c0d286..09babe2 100644 --- a/git/gitconfig +++ b/git/gitconfig @@ -1,9 +1,3 @@ -[user] - name = Austen Adler - email = stonewareslord@gmail.com - #signingkey = CCDFE3F1 -[commit] - #gpgsign=true [alias] i = "!git br&&git st" # coa = "!for i in $(git branch -a|cut -b3-|grep remotes|sed -e 's/remotes\///'|cut -d/ -f1 --complement|cut -d\ -f1);do git checkout $i;done" diff --git a/scripts/sync.sh b/scripts/sync.sh index 3498e6e..aedfc9a 100755 --- a/scripts/sync.sh +++ b/scripts/sync.sh @@ -1,84 +1,126 @@ -ABSPATH=$(\cd "$(dirname "$0")/.."; pwd) -echo $ABSPATH -while getopts ":shbc" VALUE "$@"; do - if [ "$VALUE" = "h" ] ; then - echo "sync.sh syncs configuration files, applications, and Vim bundles between computers" - echo " -h Shows this help" - echo " -b Syncs Vim bundles" - echo " -s Use this if you don't want custom stonewareslord settings (use after -s)" - echo " -c Sync configuration files" +#!/bin/bash +ABSPATH="$(\pushd >/dev/null "$(\dirname "$0")/..";\pwd;\popd >/dev/null)" +SYNC_CONFIG=0 +SHOW_HELP=0 +SYNC_CUSTOM=0 +SYNC_VIM=0 +VALID_CMD=0 +RECLONE=0 +TMP_PATH="/tmp/$(uuidgen)" +mkdir -p "$TMP_PATH" +sync_config() { + # Remove old config files + remove ~/.gitconfig ~/.bashrc ~/.pylintrc ~/.zsh ~/.zshrc ~/.tmux.conf ~/.config/liquidpromptrc ~/.config/dunstrc + # Silently remove vimperator files since we are not reinstalling + remove -s ~/.vimperatorrc ~/.vimperator/colors/vimPgray.vimp + if [[ $RECLONE = 1 ]]; then + remove ~/.fzf ~/.zsh-git fi - if [ "$VALUE" = "s" ] ; then - sed -i'' -e '/email = stonewareslord@gmail.com/d' -e '/user = Austen Adler/d' -e '/\[user\]/d' -e '/signingkey = CCDFE3F1/d' ~/.gitconfig + # Install on all systems + # Vimperator has perished. Don't install vimperator files anymore + #ln -s "$ABSPATH/vimperator/vimperatorrc" ~/.vimperatorrc + #mkdir -p ~/.vimperator/colors + #ln -s "$ABSPATH/vimperator/vimPgray.vimp" ~/.vimperator/colors/vimPgray.vimp + if command -v git 2>&1 >/dev/null; then + if command -v zsh 2>&1 >/dev/null; then + for i in lpr oh-my-git-themes omg zsh-syntax-highlighting; do + if [ ! -d ~/.zsh-git/"$i" ]; then + git clone "https://austenwares.com/gitea/stonewareslord/$i.git" ~/.zsh-git/"$i" + fi + done + fi + if [ ! -d ~/.fzf ] ; then + git clone "https://austenwares.com/gitea/stonewareslord/fzf.git" ~/.fzf + ~/.fzf/install --bin + fi + else + echo "No git! Not installing fzf or zsh packages" fi - if [ "$VALUE" = "b" ] ; then - trash ~/.vimrc || rm ~/.vimrc - ln -s $ABSPATH/vim/vimrc ~/.vimrc - vim +"silent! call Initialize()" +q - fi - if [ "$VALUE" = "c" ] ; then - if [ "$2" = "-f" ] ; then - # Reinstall antigen - rm -rf ~/.antigen - fi - echo "Syncing config files" - if command -v trash 2>&1 /dev/null; then - trash ~/.gitconfig ~/.vimperatorrc ~/.vimperator/colors/vimPgray.vimp ~/.bashrc ~/.pylintrc ~/.zsh ~/.zshrc ~/.tmux.conf ~/.config/liquidpromptrc ~/.config/dunstrc - else - rm ~/.gitconfig ~/.vimperatorrc ~/.vimperator/colors/vimPgray.vimp ~/.bashrc ~/.pylintrc ~/.zsh ~/.zshrc ~/.tmux.conf ~/.config/liquidpromptrc ~/.config/dunstrc - fi - # Install on all systems - ln -s $ABSPATH/dunst/dunstrc ~/.config/dunstrc - ln -s $ABSPATH/tmux/tmux.conf ~/.tmux.conf - ln -s $ABSPATH/python/pylintrc ~/.pylintrc - ln -s $ABSPATH/vimperator/vimperatorrc ~/.vimperatorrc - mkdir -p ~/.vimperator/colors - ln -s $ABSPATH/vimperator/vimPgray.vimp ~/.vimperator/colors/vimPgray.vimp - ln -s $ABSPATH/git/gitconfig ~/.gitconfig - ln -s $ABSPATH/shells/bashrc ~/.bashrc - ln -s $ABSPATH/zsh ~/.zsh - if command -v git 2>&1 >/dev/null; then - if command -v zsh 2>&1 >/dev/null; then - ln -s $ABSPATH/shells/zshrc ~/.zshrc - for i in lpr oh-my-git-themes omg zsh-syntax-highlighting; do - if [ ! -d ~/.zsh-git/$i ]; then - git clone https://austenwares.com/gitea/stonewareslord/$i.git ~/.zsh-git/$i - else - \cd ~/.zsh-git/$i - git pull - \cd - - fi - done - fi - if [ ! -d ~/.fzf ] ; then - git clone https://austenwares.com/gitea/stonewareslord/fzf.git ~/.fzf - ~/.fzf/install -y - fi - else - echo "No git! Not installing fzf or antigen" - fi - mkdir -p ~/.config - ln -s $ABSPATH/shells/liquidpromptrc ~/.config/liquidpromptrc - if [ "$(uname)" != "Darwin" ]; then - if command -v trash 2>&1 >/dev/null; then - trash ~/.i3/{config,i3status.conf,run.sh} ~/.Xmodmap ~/.xsession ~/.config/synapse/gtkrc ~/.Xresources - else - rm ~/.i3/{config,i3status.conf,run.sh} ~/.Xmodmap ~/.xsession ~/.config/synapse/gtkrc ~/.Xresources - fi - # Don't install these on Mac - mkdir -p ~/.i3 - ln -s $ABSPATH/i3/config ~/.i3/config - ln -s $ABSPATH/i3/$(hostname)-status.conf ~/.i3/i3status.conf 2>/dev/null - ln -s $ABSPATH/i3/run.sh ~/.i3/run.sh - ln -s $ABSPATH/i3/Xmodmap ~/.Xmodmap - ln -s $ABSPATH/i3/xsession ~/.xsession - mkdir -p ~/.config/synapse - ln -s $ABSPATH/i3/gtkrc ~/.config/synapse/gtkrc - ln -s $ABSPATH/shells/Xresources ~/.Xresources - if command -v xrdb 2>&1 >/dev/null; then - xrdb ~/.Xresources - fi + mkdir -p ~/.config + ln -s "$ABSPATH/dunst/dunstrc" ~/.config/dunstrc + ln -s "$ABSPATH/tmux/tmux.conf" ~/.tmux.conf + ln -s "$ABSPATH/python/pylintrc" ~/.pylintrc + ln -s "$ABSPATH/git/gitconfig" ~/.gitconfig + ln -s "$ABSPATH/shells/bashrc" ~/.bashrc + ln -s "$ABSPATH/shells/zshrc" ~/.zshrc + ln -s "$ABSPATH/zsh" ~/.zsh + ln -s "$ABSPATH/shells/liquidpromptrc" ~/.config/liquidpromptrc + if [ "$(uname)" != "Darwin" ]; then + # Don't install these on Mac + remove ~/.i3/{config,i3status.conf,run.sh} ~/.Xmodmap ~/.xsession ~/.config/synapse/gtkrc ~/.Xresources + mkdir -p ~/.i3 ~/.config/synapse + ln -s "$ABSPATH/i3/config" ~/.i3/config + ln -s "$ABSPATH/i3/$(hostname)-status.conf" ~/.i3/i3status.conf 2>/dev/null + ln -s "$ABSPATH/i3/run.sh" ~/.i3/run.sh + ln -s "$ABSPATH/i3/Xmodmap" ~/.Xmodmap + ln -s "$ABSPATH/i3/xsession" ~/.xsession + ln -s "$ABSPATH/i3/gtkrc" ~/.config/synapse/gtkrc + ln -s "$ABSPATH/shells/Xresources" ~/.Xresources + if command -v xrdb 2>&1 >/dev/null; then + xrdb ~/.Xresources fi fi +} +sync_custom() { + if ! command -v git 2>&1 >/dev/null; then + echo "Error! No git -- can't sync custom files" + exit + fi + if [[ ! -d ~/.zsh-git/custom-config ]]; then + #TODO: Figure out if I should use ssh or https cloning + #git clone https://austenwares.com/gitea/stonewareslord/custom-config + git clone git@austenwares.com:stonewareslord/custom-config ~/.zsh-git/custom-config + fi + remove ~/.gitconfig + ln -s ~/.zsh-git/custom-config/gitconfig ~/.gitconfig + # Custom zsh is sourced from zshrc +} +sync_vim() { + remove ~/.vimrc + ln -s "$ABSPATH/vim/vimrc" ~/.vimrc + vim +"silent! call Initialize()" +q +} +show_help() { + echo "sync.sh syncs configuration files and Vim plugins on computers" + echo " -h Shows this help" + echo " -b Syncs Vim bundles" + echo " -s Use this if you want custom stonewareslord settings" + echo " -c Sync configuration files" + echo " -r Reclone all git repositories" + exit +} +remove() { + local SILENT=0 + if [[ "$1" = "-s" ]]; then + # Be quiet! + SILENT=1 + fi + if [[ $SILENT = 1 ]]; then + \mv -t "$TMP_PATH" $* 2>/dev/null + else + \mv -t "$TMP_PATH" $* + fi +} +while getopts ":shbc" OPT "$@"; do + case $OPT in + b) SYNC_VIM=1;VALID_CMD=1;; + s) SYNC_CUSTOM=1;; + c) SYNC_CONFIG=1;VALID_CMD=1;; + r) RECLONE=1;; + *) SHOW_HELP=1;; + esac done +if [[ $SHOW_HELP = 1 ]] || [[ ! $VALID_CMD = 1 ]]; then + show_help +fi +echo "Syncing config files. Placing old files in $TMP_PATH" +if [[ $SYNC_CONFIG = 1 ]]; then + sync_config + if [[ $SYNC_CUSTOM = 1 ]]; then + sync_custom + fi +fi +if [[ $SYNC_VIM = 1 ]]; then + sync_vim +fi echo "Done syncing" diff --git a/shells/zshrc b/shells/zshrc index 3def0a3..e41024f 100644 --- a/shells/zshrc +++ b/shells/zshrc @@ -1,8 +1,6 @@ -# Borg backup repository -export BORG_REPO="aw:borg" #zmodload zsh/zprof echo -ne '[ ]\r' -for config (~/.zsh/*.zsh) source $config +for CONFIG (~/.zsh/*.zsh) source "$CONFIG" autoload -U compinit compinit setopt always_to_end # When completing from the middle of a word, move the cursor to the end of the word @@ -13,7 +11,7 @@ setopt HIST_EXPIRE_DUPS_FIRST export HIST_STAMPS="dd.mm.yyyy" export HISTSIZE=12000 export SAVEHIST=10000000 -export HISTFILE=$HOME/.zsh_history +export HISTFILE="$HOME/.zsh_history" setopt APPEND_HISTORY setopt EXTENDED_HISTORY setopt APPEND_HISTORY SHARE_HISTORY HISTIGNOREALLDUPS @@ -515,20 +513,6 @@ hsh(){ echo pv "$FILE" \| pee $ARGS pv "$FILE" | pee $(echo $ARGS) } -enc() { - test -f README.md || echo "# enc\n## files" > README.md - while (( $# > 0 )) ; do - fn="$1" - uuid="$(uuidgen)" - shift - echo "Encrypting ($fn)..." - pv "$fn" | gpg -r stonewareslord -o "$uuid" -e - || (echo "Error encrypting $fn" >&2 ; continue) - echo "- \`$uuid\`: \`$fn\`" >> README.md || (echo "Error appending $fn to README.md" >&2 ; continue) - echo "Calculating sum of ($fn) in the background" - pv "$uuid" | sha512sum | perl -pe "s/-/$uuid/" >> SHA512SUMS || (echo "Error calculating sum of $uuid" >&2 ; continue) - rm "$fn" || (echo "Error removing $fn"; continue) - done -} rc(){ case $1 in z) vim ~/.zshrc;; @@ -544,19 +528,6 @@ rc(){ *) echo "Opts:\nz v i\nuse make unmask mask accept_keywords keywords license" esac } -pub-git-init(){ - # Get the project name - branch=$(git remote -v | ag '^origin\s+' | sed -e 's/^origin\s*//' | cut -d\ -f1 | sed -r -e 's/^.+\///' -e 's/#.+$//' -e 's/\.git$//' | head -n1) - echo "Branch: $branch" - # Get the hashed project name - enc_branch=$(echo "$branch" | sha512sum | cut -d\ -f1) - git remote add local "gcrypt::git@localhost:stonewareslord/79a79b1a6e37813d9226872c6428aca29eec9f6111558109861cb0dcd2f0ffc8198deea4e361f84e170989212452fdfb21e0ef690da2ad399c03ce308d79dcfe#$enc_branch" - git remote add ncsu "gcrypt::git@github.ncsu.edu:agadler/a86a0f8757772be2ec617b395a0716679bfce51c1bfdeb8da6127feebd84facde645e9e30188318344eb458f5834e3d86800.git#$enc_branch" - git remote add gitlab "gcrypt::git@gitlab.com:stonewareslord/e6e03ea006d55de0970a28bcb7fcf65f4c66f98f50830bd69b50c5dc502bdf1a4e4172187cfb5fcef8c32bd7fb316bdc67d7d86713ebfe232f97eb303ac316ae.git#$enc_branch" - git remote add aws "gcrypt::git@aws:stonewareslord/5e0701d5b5b2118127d378c084be9a1dfb33d185d3e2c5da30a3984f5118e3d5136f3f3b038462bccd538e93f9e32cb06136.git#$enc_branch" - git config remote.ncsu.gcrypt-participants "CCDFE3F1" - git config remote.gitlab.gcrypt-participants "CCDFE3F1" -} pub-git-rm(){ if (( $# == 0 )) ; then git remote rm local @@ -581,22 +552,6 @@ pub-git-push(){ shift done } -pub-git-clone(){ - case $1 in - ncsu) remote="gcrypt::git@github.ncsu.edu:agadler/a86a0f8757772be2ec617b395a0716679bfce51c1bfdeb8da6127feebd84facde645e9e30188318344eb458f5834e3d86800.git#" ;; - gitlab) remote="gcrypt::git@gitlab.com:stonewareslord/e6e03ea006d55de0970a28bcb7fcf65f4c66f98f50830bd69b50c5dc502bdf1a4e4172187cfb5fcef8c32bd7fb316bdc67d7d86713ebfe232f97eb303ac316ae.git#" ;; - local) remote="gcrypt::git@localhost:stonewareslord/79a79b1a6e37813d9226872c6428aca29eec9f6111558109861cb0dcd2f0ffc8198deea4e361f84e170989212452fdfb21e0ef690da2ad399c03ce308d79dcfe#" ;; - aws) remote="gcrypt::git@aws:stonewareslord/5e0701d5b5b2118127d378c084be9a1dfb33d185d3e2c5da30a3984f5118e3d5136f3f3b038462bccd538e93f9e32cb06136.git#" ;; - *) echo "Opts: local ncsu gitlab" ; return 1 - esac - shift - if [ -z "$1" ] ; then - echo "No arg2" - return 2 - fi - branch=$(echo $1 | sha512sum | cut -d\ -f1) - git clone "$remote$branch" $1 -} k(){ #More than 1 arguement if [[ $# > 1 ]] ; then @@ -669,5 +624,8 @@ source ~/.zsh-git/lpr/liquidprompt source ~/.zsh-git/omg/base.sh source ~/.zsh-git/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh source ~/.zsh-git/oh-my-git-themes/af-magic.zsh-theme +if [[ -f ~/.zsh-git/zshrc ]]; then + source ~/.zsh-git/zshrc +fi echo -e '[##]' #zprof diff --git a/vim/vimrc b/vim/vimrc index c422d9f..1d3b2b1 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -374,34 +374,30 @@ endif silent! colorscheme fruity function! Initialize() if has("win32") - if empty(glob("~/_vim/autoload/plug.vim")) - cd ~ - silent !mkdir vimfiles - cd vimfiles - silent !mkdir autoload - silent !mkdir plugin - silent !mkdir backup - silent !mkdir undo - silent !mkdir tmp - cd autoload - silent !powershell -command "& { iwr https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim -OutFile plug.vim }" - silent! so ~/_vimrc - silent! PlugInstall - q - endif + cd ~ + silent !mkdir vimfiles + cd vimfiles + silent !mkdir autoload + silent !mkdir plugin + silent !mkdir backup + silent !mkdir undo + silent !mkdir tmp + cd autoload + silent !powershell -command "& { iwr https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim -OutFile plug.vim }" + silent! so ~/_vimrc else - if empty(glob("~/.vim/autoload/plug.vim")) - silent !mkdir -p ~/.vim/autoload - silent !mkdir -p ~/.vim/plugin - silent !mkdir -p ~/.vim/backup - silent !mkdir -p ~/.vim/undo - silent !mkdir -p ~/.vim/tmp - silent !curl -fLo ~/.vim/autoload/plug.vim https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim - silent! so ~/.vimrc - silent! PlugInstall - q - endif + silent !mkdir -p ~/.vim/autoload + silent !mkdir -p ~/.vim/plugin + silent !mkdir -p ~/.vim/backup + silent !mkdir -p ~/.vim/undo + silent !mkdir -p ~/.vim/tmp + silent !curl -fLo ~/.vim/autoload/plug.vim https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + silent! so ~/.vimrc endif + silent! PlugClean! + silent! PlugUpdate + silent! PlugInstall + q endfunction if !exists('g:ycm_semantic_triggers') let g:ycm_semantic_triggers = {}