Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 529 lines (470 sloc) 14.5 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 snippet {
dest="${2:-${1}}"
cp ~/.snippets/"${1}"/"${1}" ~/scripts/"${dest}"
}
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 repos aren'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
if [[ -d ~/.snippets/.git ]] ; then
ensure cd ~/.snippets
ensure git fetch origin --quiet > /dev/null
ensure git merge origin/master > /dev/null
else
ensure rm -rf ~/.snippets
ensure git clone https://github.com/woodruffw/snippets ~/.snippets > /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
snippet 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 urlview..."
if installed urlview ; then
printf "found. Reloading config..."
cp ~/.dotfiles/urlview ~/.urlview
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 ffox, pipefox and ff2mpv..."
cp ~/.dotfiles/scripts/ffox ~/scripts/ffox
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 "Checking for neomutt..."
if installed neomutt; then
printf "found. Reloading config..."
cp ~/.dotfiles/muttrc ~/.muttrc
mkdir -p ~/.mutt
cp -R ~/.dotfiles/mutt/* ~/.mutt
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/pbin ~/scripts/pbin
cp ~/.dotfiles/scripts/update ~/scripts/update
cp ~/.dotfiles/scripts/cart ~/scripts/cart
cp ~/.dotfiles/scripts/speedtest ~/scripts/speedtest
cp ~/.dotfiles/scripts/worldtimes ~/scripts/worldtimes
cp ~/.dotfiles/scripts/diff-highlight ~/scripts/diff-highlight
cp ~/.dotfiles/scripts/fwuf ~/scripts/fwuf
cp ~/.dotfiles/scripts/aaa ~/scripts/aaa
cp ~/.dotfiles/scripts/selecta ~/scripts/selecta
cp ~/.dotfiles/scripts/update-hosts ~/scripts/update-hosts
cp ~/.dotfiles/scripts/license ~/scripts/license
cp ~/.dotfiles/scripts/bak ~/scripts/bak
cp ~/.dotfiles/scripts/psh ~/scripts/psh
cp ~/.dotfiles/scripts/nth ~/scripts/nth
snippet fftitle
snippet fftimelapse
snippet ffnicegif
snippet ffcat
snippet ffflagflip
snippet ffwatermark
snippet ffautocrop
snippet ffclip
snippet ffpreclip
snippet ffpostclip
snippet ffpip
snippet ffmono
snippet ffreverse
snippet ffmonochrome
snippet ffboxblur
snippet ffgolapse
snippet ffdeshake
snippet ffstill
snippet urlgrep
snippet albumart
snippet rip
snippet flac2mp3
snippet mp3art
snippet flacart
snippet uspatent
snippet gif-length-groups
snippet giphy-fetch
snippet ffmpeg-mosaic
snippet normalize-gifs
snippet rubyvm-dump
snippet git-gem-release-tag
snippet git-shard-release-tag
snippet git-fetch-pr
snippet git-lint-commit
snippet git-move-commits
snippet git-open-all
snippet git-takeout
snippet ronnpp
snippet linecheck
snippet imgresize
snippet ssqdb
if [[ "${system}" = "Darwin" ]]; then
cp ~/.dotfiles/scripts/osx-vnc-password ~/scripts/osx-vnc-password
cp ~/.dotfiles/scripts/darktoggle ~/scripts/darktoggle
cp -R ~/.dotfiles/gnupg/* ~/.gnupg
fi
if [[ "${host}" = "mercury" || "${host}" = "janus" ]] ; then
cp ~/.dotfiles/scripts/poomf ~/scripts/poomf
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/xyzradio ~/scripts/xyzradio
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/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/bootlin ~/scripts/bootlin
cp ~/.dotfiles/scripts/geocode ~/scripts/geocode
cp ~/.dotfiles/scripts/geoopen ~/scripts/geoopen
snippet play
snippet vboxssh
snippet xontop
snippet tal
snippet radio
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
snippet vbnla
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 ~/scripts/last-photo
rm -f ~/scripts/last-snap
rm -f ~/scripts/last-recording
rm -f ~/scripts/pid2xid
rm -f ~/scripts/bug-roommates
rm -f ~/scripts/mp4flip
rm -f ~/scripts/forecast
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@github.com:woodruffw/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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.