Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 485 lines (434 sloc) 15.3 KB
#!/usr/bin/env bash
# dotfiles: fetch configuration files and scripts
# usage: dotfiles
# this file is disgusting, and will never be fixed.
function installed {
cmd=$(command -v "${1}")
[[ -n "${cmd}" ]] && [[ -f "${cmd}" ]]
return ${?}
}
function running {
pids=$(pidof "${1}")
[[ -n "${pids}" ]]
return ${?}
}
function green {
echo -e "${COLOR_GRN}${*}${COLOR_NRM}"
}
function yellow {
echo -e "${COLOR_YLW}${*}${COLOR_NRM}"
}
function die {
echo "Error: $*" >&2
exit 1
}
function ensure {
"$@" \
|| die "Failed to run '$*'. Aborting."
}
function fetch_files {
system=$(uname)
host=$(hostname)
if ! installed git ; then
die "git required to fetch configs."
exit 1
fi
pushd . > /dev/null
# make sure the repo isn't clobbered
if [[ -d ~/.dotfiles/.git ]] ; then
ensure cd ~/.dotfiles
ensure git fetch origin --quiet > /dev/null
ensure git merge origin/master > /dev/null
else
ensure rm -rf ~/.dotfiles
ensure git clone https://github.com/woodruffw/dotfiles ~/.dotfiles > /dev/null
fi
popd > /dev/null
mkdir -p ~/scripts
printf "Reloading bashrc, inputrc, profile, and completions..."
cp ~/.dotfiles/bashrc ~/.bashrc
cp ~/.dotfiles/inputrc ~/.inputrc
cp ~/.dotfiles/profile ~/.profile
cp ~/.dotfiles/bash_completion ~/.bash_completion
mkdir -p ~/.bash_completion.d
cp -R ~/.dotfiles/bash_completion.d/* ~/.bash_completion.d
green "done"
# we know git is installed
printf "Reloading git-aliases, gitignore, and gitconfig..."
cp ~/.dotfiles/gitignore ~/.gitignore
cp ~/.dotfiles/gitconfig ~/.gitconfig
green "done"
printf "Checking for curl..."
if installed curl ; then
printf "found. Reloading curlrc..."
cp ~/.dotfiles/curlrc ~/.curlrc
green "done"
else
yellow "not installed. Skipping"
fi
printf "Checking for rtorrent..."
if installed rtorrent ; then
printf "found. Reloading rtorrent.rc and magnet scripts..."
if [[ -f ~/.dotfiles/rtorrent-"${host}".rc ]]; then
cp ~/.dotfiles/rtorrent-"${host}".rc ~/.rtorrent.rc
else
yellow "skipping rtorrent.rc."
fi
green "done"
else
yellow "not installed. Skipping"
fi
printf "Checking for tmux..."
if installed tmux ; then
printf "found. Reloading tmux.conf and session files..."
cp ~/.dotfiles/tmux.conf ~/.tmux.conf
mkdir -p ~/.tmux
cp ~/.dotfiles/tmux/* ~/.tmux/
green "done"
else
yellow "not installed. Skipping"
fi
printf "Checking for hexchat..."
if installed hexchat ; then
printf "found. Reloading configs and addons..."
mkdir -p ~/.config/hexchat
cp -R ~/.dotfiles/config/hexchat/* ~/.config/hexchat/
green "done"
else
yellow "not installed. Skipping"
fi
printf "Checking for mpv..."
if installed mpv ; then
printf "found. Reloading configs..."
mkdir -p ~/.mpv/{scripts,script-opts}
cp ~/.dotfiles/mpv/config ~/.mpv/config
cp ~/.dotfiles/mpv/input.conf ~/.mpv/input.conf
cp ~/.dotfiles/mpv/scripts/* ~/.mpv/scripts/
cp ~/.dotfiles/mpv/script-opts/osc.conf ~/.mpv/script-opts/osc.conf
green "done"
else
yellow "not installed. Skipping"
fi
printf "Checking for feh..."
if installed feh ; then
printf "found. Reloading themes, fehbg, and wallpaper..."
mkdir -p ~/.config/feh
cp ~/.dotfiles/config/feh/themes ~/.config/feh/themes
cp ~/.dotfiles/fehbg ~/.fehbg
cp ~/.dotfiles/config/feh/wallpaper ~/.config/feh/wallpaper
green "done"
else
yellow "not installed. Skipping"
fi
printf "Checking for newsboat..."
if installed newsboat ; then
printf "found. Reloading config and scripts..."
mkdir -p ~/.config/newsboat
cp ~/.dotfiles/config/newsboat/config ~/.config/newsboat/config
cp ~/.dotfiles/scripts/newsboat-yt-feed ~/scripts/newsboat-yt-feed
green "done"
else
yellow "not installed. Skipping"
fi
printf "Checking for Sublime Text..."
if installed subl ; then
printf "found. Reloading preferences and themes..."
cp -R ~/.dotfiles/config/sublime-text-3/* ~/.config/sublime-text-3
cp -R ~/.dotfiles/editorconfig ~/.editorconfig
green "done"
else
yellow "not installed. Skipping"
fi
printf "Checking for ruby..."
if installed ruby ; then
printf "found. Reloading bundle config, irbrc, gemrc, and rubocop.yml..."
mkdir -p ~/.bundle
cp ~/.dotfiles/bundle/config ~/.bundle/config
cp ~/.dotfiles/irbrc ~/.irbrc
cp ~/.dotfiles/gemrc ~/.gemrc
cp ~/.dotfiles/rubocop.yml ~/.rubocop.yml
green "done"
else
yellow "not installed. Skipping"
fi
printf "Checking for urxvt..."
if installed urxvt ; then
printf "found. Reloading Xdefaults and extensions..."
cp ~/.dotfiles/Xdefaults ~/.Xdefaults
mkdir -p ~/.urxvt/ext
cp -R ~/.dotfiles/urxvt/ext/* ~/.urxvt/ext
green "done"
else
yellow "not installed. Skipping"
fi
printf "Checking for LaTeX..."
if installed latex ; then
printf "found. Reloading texmf and updating the database..."
mkdir -p ~/texmf
cp -R ~/.dotfiles/texmf/* ~/texmf
installed texhash && texhash > /dev/null 2>&1
green "done"
else
yellow "not installed. Skipping"
fi
printf "Checking for Firefox..."
if installed firefox && ! running firefox ; then
printf "found. Reloading pipefox and ff2mpv..."
cp ~/.dotfiles/scripts/pipefox ~/scripts/pipefox
cp ~/.dotfiles/scripts/ff2mpv ~/scripts/ff2mpv
mkdir -p ~/.mozilla/native-messaging-hosts/
cp ~/.dotfiles/mozilla/native-messaging-hosts/ff2mpv.json ~/.mozilla/native-messaging-hosts
green "done"
elif running firefox ; then
# Recent versions of Firefox lock up when native manifests are updated (even if not
# actually changed) while running.
yellow "not reloading while Firefox is running. Skipping"
else
yellow "not installed. Skipping"
fi
printf "Checking for Google Chrome..."
if installed google-chrome ; then
printf "found. Reloading app scripts..."
cp ~/.dotfiles/scripts/netflix ~/scripts/netflix
cp ~/.dotfiles/scripts/plex ~/scripts/plex
green "done"
else
yellow "not installed. Skipping"
fi
printf "Checking for i3..."
if installed i3 ; then
printf "found. Reloading config and scripts..."
cp ~/.dotfiles/config/i3/config-"${host}" ~/.config/i3/config
cp ~/.dotfiles/i3status-"${host}".conf ~/.i3status.conf
cp ~/.dotfiles/Xmodmap ~/.Xmodmap
cp ~/.dotfiles/config/i3/statusbar ~/.config/i3/statusbar
cp ~/.dotfiles/scripts/monitors-"${host}" ~/scripts/monitors
if [[ -f ~/.dotfiles/scripts/workspaces-"${host}" ]]; then
cp ~/.dotfiles/scripts/workspaces-"${host}" ~/scripts/workspaces
mkdir -p ~/.config/i3/workspaces
if [[ "${host}" = "mercury" ]]; then
for ws in com dev www; do
cp ~/.dotfiles/config/i3/workspaces/"${ws}".json ~/.config/i3/workspaces
done
elif [[ "${host}" = "janus" ]]; then
for ws in 1A 1B 1C 2A; do
cp ~/.dotfiles/config/i3/workspaces/"${ws}".json ~/.config/i3/workspaces
done
fi
fi
green "done"
else
yellow "not installed. Skipping"
fi
printf "Checking for kbsecret..."
if installed kbsecret ; then
printf "found. Reloading scripts..."
cp ~/.dotfiles/scripts/kbsecret-yad-login ~/scripts/kbsecret-yad-login
cp ~/.dotfiles/scripts/kbsecret-dmenu-pass ~/scripts/kbsecret-dmenu-pass
cp ~/.dotfiles/scripts/kbsecret-snip ~/scripts/kbsecret-snip
cp ~/.dotfiles/scripts/kbsecret-todo-list ~/scripts/kbsecret-todo-list
cp ~/.dotfiles/scripts/kbsecret-discover-sessions ~/scripts/kbsecret-discover-sessions
cp ~/.dotfiles/scripts/kbsecret-recovery ~/scripts/kbsecret-recovery
cp ~/.dotfiles/scripts/kbsecret-audit-pass ~/scripts/kbsecret-audit-pass
cp ~/.dotfiles/scripts/kbsecret-zxcvbn ~/scripts/kbsecret-zxcvbn
cp ~/.dotfiles/scripts/kbsecret-qr ~/scripts/kbsecret-qr
cp ~/.dotfiles/scripts/todo ~/scripts/todo
cp ~/.dotfiles/scripts/snip ~/scripts/snip
green "done"
else
yellow "not installed. Skipping"
fi
printf "Checking for uzbl..."
if installed uzbl ; then
printf "found. Reloading config..."
cp ~/.dotfiles/config/uzbl/config ~/.config/uzbl/config
green "done"
else
yellow "not installed. Skipping"
fi
printf "Checking for Spotify..."
if installed spotify; then
printf "found. Reloading scripts..."
cp ~/.dotfiles/scripts/sp ~/scripts/sp
green "done"
else
yellow "not installed. Skipping"
fi
printf "Checking for fontconfig..."
if installed fc-cache; then
printf "found. Reloading fonts.conf..."
mkdir -p ~/.config/fontconfig
cp ~/.dotfiles/config/fontconfig/fonts.conf ~/.config/fontconfig/fonts.conf
green "done"
else
yellow "not installed. Skipping"
fi
printf "Checking for youtube-dl..."
if installed youtube-dl; then
printf "found. Reloading config..."
mkdir -p ~/.config/youtube-dl
cp ~/.dotfiles/config/youtube-dl/config ~/.config/youtube-dl/config
green "done"
else
yellow "not installed. Skipping"
fi
printf "Fetching scripts..."
cp ~/.dotfiles/scripts/dotfiles ~/scripts/dotfiles.new
cp ~/.dotfiles/scripts/colormake ~/scripts/colormake
cp ~/.dotfiles/scripts/linecheck ~/scripts/linecheck
cp ~/.dotfiles/scripts/pbin ~/scripts/pbin
cp ~/.dotfiles/scripts/update ~/scripts/update
cp ~/.dotfiles/scripts/cart ~/scripts/cart
cp ~/.dotfiles/scripts/speedtest ~/scripts/speedtest
cp ~/.dotfiles/scripts/rip ~/scripts/rip
cp ~/.dotfiles/scripts/flac2mp3 ~/scripts/flac2mp3
cp ~/.dotfiles/scripts/mp3art ~/scripts/mp3art
cp ~/.dotfiles/scripts/flacart ~/scripts/flacart
cp ~/.dotfiles/scripts/worldtimes ~/scripts/worldtimes
cp ~/.dotfiles/scripts/diff-highlight ~/scripts/diff-highlight
cp ~/.dotfiles/scripts/uspatent ~/scripts/uspatent
cp ~/.dotfiles/scripts/pid2xid ~/scripts/pid2xid
cp ~/.dotfiles/scripts/albumart ~/scripts/albumart
cp ~/.dotfiles/scripts/fwuf ~/scripts/fwuf
cp ~/.dotfiles/scripts/aaa ~/scripts/aaa
cp ~/.dotfiles/scripts/selecta ~/scripts/selecta
cp ~/.dotfiles/scripts/ffmpeg-mosaic ~/scripts/ffmpeg-mosaic
cp ~/.dotfiles/scripts/gif-length-groups ~/scripts/gif-length-groups
cp ~/.dotfiles/scripts/giphy-fetch ~/scripts/giphy-fetch
cp ~/.dotfiles/scripts/normalize-gifs ~/scripts/normalize-gifs
cp ~/.dotfiles/scripts/last-photo ~/scripts/last-photo
cp ~/.dotfiles/scripts/last-snap ~/scripts/last-snap
cp ~/.dotfiles/scripts/last-recording ~/scripts/last-recording
cp ~/.dotfiles/scripts/forecast ~/scripts/forecast
cp ~/.dotfiles/scripts/rubyvm-dump ~/scripts/rubyvm-dump
cp ~/.dotfiles/scripts/update-hosts ~/scripts/update-hosts
cp ~/.dotfiles/scripts/license ~/scripts/license
cp ~/.dotfiles/scripts/bak ~/scripts/bak
cp ~/.dotfiles/scripts/git-gem-release-tag ~/scripts/git-gem-release-tag
cp ~/.dotfiles/scripts/git-shard-release-tag ~/scripts/git-shard-release-tag
cp ~/.dotfiles/scripts/git-fetch-pr ~/scripts/git-fetch-pr
cp ~/.dotfiles/scripts/git-lint-commit ~/scripts/git-lint-commit
cp ~/.dotfiles/scripts/git-move-commits ~/scripts/git-move-commits
cp ~/.dotfiles/scripts/git-open-all ~/scripts/git-open-all
cp ~/.dotfiles/scripts/ronnpp ~/scripts/ronnpp
cp ~/.dotfiles/scripts/psh ~/scripts/psh
cp ~/.dotfiles/scripts/nth ~/scripts/nth
cp ~/.dotfiles/scripts/mp4flip ~/scripts/mp4flip
cp ~/.dotfiles/scripts/fftitle ~/scripts/fftitle
cp ~/.dotfiles/scripts/fftimelapse ~/scripts/fftimelapse
cp ~/.dotfiles/scripts/ffnicegif ~/scripts/ffnicegif
cp ~/.dotfiles/scripts/ffcat ~/scripts/ffcat
cp ~/.dotfiles/scripts/ffflagflip ~/scripts/ffflagflip
cp ~/.dotfiles/scripts/ffwatermark ~/scripts/ffwatermark
cp ~/.dotfiles/scripts/ffautocrop ~/scripts/ffautocrop
cp ~/.dotfiles/scripts/ffclip ~/scripts/ffclip
cp ~/.dotfiles/scripts/ffpreclip ~/scripts/ffpreclip
cp ~/.dotfiles/scripts/ffpostclip ~/scripts/ffpostclip
cp ~/.dotfiles/scripts/ffpip ~/scripts/ffpip
cp ~/.dotfiles/scripts/ffmono ~/scripts/ffmono
cp ~/.dotfiles/scripts/ffreverse ~/scripts/ffreverse
cp ~/.dotfiles/scripts/ffmonochrome ~/scripts/ffmonochrome
cp ~/.dotfiles/scripts/ffboxblur ~/scripts/ffboxblur
cp ~/.dotfiles/scripts/ffgolapse ~/scripts/ffgolapse
cp ~/.dotfiles/scripts/ffdeshake ~/scripts/ffdeshake
cp ~/.dotfiles/scripts/ffstill ~/scripts/ffstill
cp ~/.dotfiles/scripts/imgresize ~/scripts/imgresize
cp ~/.dotfiles/scripts/urlgrep ~/scripts/urlgrep
if [[ "${system}" = "Darwin" ]]; then
cp ~/.dotfiles/scripts/osx-vnc-password ~/scripts/osx-vnc-password
cp -R ~/.dotfiles/gnupg/* ~/.gnupg
fi
if [[ "${host}" = "mercury" || "${host}" = "janus" ]] ; then
cp ~/.dotfiles/scripts/poomf ~/scripts/poomf
cp ~/.dotfiles/scripts/play ~/scripts/play
cp ~/.dotfiles/scripts/play-xclip ~/scripts/play-xclip
cp ~/.dotfiles/scripts/uzbl-xclip ~/scripts/uzbl-xclip
cp ~/.dotfiles/scripts/twitch-"${host}" ~/scripts/twitch
cp ~/.dotfiles/scripts/radio ~/scripts/radio
cp ~/.dotfiles/scripts/xyzradio ~/scripts/xyzradio
cp ~/.dotfiles/scripts/xontop ~/scripts/xontop
cp ~/.dotfiles/scripts/tal ~/scripts/tal
cp ~/.dotfiles/scripts/byzanz-rect ~/scripts/byzanz-rect
cp ~/.dotfiles/scripts/brewnav ~/scripts/brewnav
cp ~/.dotfiles/scripts/subreddit-watch ~/scripts/subreddit-watch
cp ~/.dotfiles/scripts/ezsshfs ~/scripts/ezsshfs
cp ~/.dotfiles/scripts/open-pdf ~/scripts/open-pdf
cp ~/.dotfiles/scripts/bug-roommates ~/scripts/bug-roommates
cp ~/.dotfiles/scripts/music ~/scripts/music
cp ~/.dotfiles/scripts/nft ~/scripts/nft
cp ~/.dotfiles/scripts/google ~/scripts/google
cp ~/.dotfiles/scripts/ytsearch ~/scripts/ytsearch
cp ~/.dotfiles/scripts/ytsearch2 ~/scripts/ytsearch2
cp ~/.dotfiles/scripts/slopcast ~/scripts/slopcast
cp ~/.dotfiles/scripts/remind ~/scripts/remind
cp ~/.dotfiles/scripts/ghbrowse ~/scripts/ghbrowse
cp ~/.dotfiles/scripts/screenlock ~/scripts/screenlock
cp ~/.dotfiles/scripts/latin ~/scripts/latin
cp ~/.dotfiles/scripts/vboxssh ~/scripts/vboxssh
cp ~/.dotfiles/scripts/geocode ~/scripts/geocode
cp ~/.dotfiles/scripts/geoopen ~/scripts/geoopen
mkdir -p ~/.local/share/file-manager/actions/
cp ~/.dotfiles/local/share/file-manager/actions/*.desktop ~/.local/share/file-manager/actions/
fi
if [[ "${host}" = "athena" ]] ; then
cp ~/.dotfiles/scripts/wwwbackup ~/scripts/wwwbackup
cp ~/.dotfiles/scripts/twitter-fortune-bot.pl ~/scripts/twitter-fortune-bot.pl
fi
chmod +x ~/scripts/*
green "done"
printf "Doing some cleanup..."
rm -rf ~/scripts/cron/
rm -f ~/scripts/$
rm -f ~/scripts/%
rm -f ~/scripts/haste
rm -f ~/scripts/mpv-xclip
rm -f ~/scripts/surf-xclip
rm -f ~/scripts/email-fwd.rb
rm -f ~/scripts/magnet-to-torrent.pl
rm -f ~/scripts/tepm
rm -f ~/scripts/kbsecret-zen-login
rm -f ~/scripts/xdcc
rm -f ~/scripts/colorscheme
rm -f ~/scripts/colorscheme2
rm -f ~/scripts/twitter-github-bot.rb
rm -f ~/scripts/nicegif
rm -f ~/scripts/dailymail.rb
rm -f ~/scripts/subsonic
rm -f ~/scripts/cskel
rm -f ~/scripts/jskel
rm -f ~/scripts/afs-umd
rm -f ~/scripts/streamable-upload
rm -f ~/scripts/mdmath
rm -f ~/scripts/muzak-now-playing
rm -f ~/scripts/muzak-rebase-index
rm -f ~/scripts/muzak-9menu
rm -f ~/scripts/screenfetch
rm -f ~/scripts/sms
rm -f ~/scripts/statusbar
rm -f ~/scripts/newsbeuter-yt-feed
rm -f ~/scripts/nautilus-xenial-gopro-install
rm -f ~/scripts/a2dp
rm -f ~/scripts/speaker
rm -f ~/scripts/microsoft-mouse
rm -f ~/scripts/magnet.sh
rm -f ~/.xsession-errors
rm -f ~/.xsession-errors.old
rm -f ~/.git-aliases
rm -f ~/.tepmrc
rm -rf ~/.newsbeuter
rm -rf ~/.mpv/lua-settings/
rm -rf ~/.config/newsbeuter
green "done"
printf "Sync dotfiles-priv? (y/N): " && read -r ans
if [[ -n $ans && "${ans}" =~ [Yy] ]] ; then
ensure git clone git@gitlab.com:yossarian/dotfiles-priv.git ~/.dotfiles-priv 2> /dev/null
pushd . > /dev/null
ensure cd ~/.dotfiles-priv
ensure bash ./install.sh
popd > /dev/null
ensure rm -rf ~/.dotfiles-priv
fi
green "All done"
}
fetch_files
mv ~/scripts/dotfiles.new ~/scripts/dotfiles