Created
August 16, 2015 05:10
-
-
Save oconnor663/5aaaf941a9c1606450fa to your computer and use it in GitHub Desktop.
dotfiles install script comparison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import os | |
from pathlib import Path | |
from shutil import which | |
from subprocess import run | |
import sys | |
here = Path(__file__).parent.resolve() | |
os.chdir(str(here)) | |
if here != Path.home()/"dotfiles": | |
print("can only be installed from ~/dotfiles") | |
sys.exit(1) | |
run("peru sync", shell=True, check=True) | |
newshell = "/bin/zsh" | |
oldshell = os.environ.get("SHELL") | |
if oldshell != newshell: | |
print("Switching default shell from {} to {}..." | |
.format(oldshell, newshell)) | |
run("chsh -s " + newshell) | |
def link(src, dest): | |
dest = Path(dest).expanduser() | |
dest.parent.mkdir(exist_ok=True, parents=True) | |
if dest.exists(): | |
dest.unlink() | |
os.symlink(str(here/src), str(dest)) | |
link("ackrc", "~/.ackrc") | |
link("gitconfig", "~/.gitconfig") | |
link("hgrc", "~/.hgrc") | |
link("tmux.conf", "~/.tmux.conf") | |
link("tmux.desktop", "~/.local/share/applications/tmux.desktop") | |
link("vim", "~/.vim") | |
link("vimrc", "~/.vimrc") | |
link("zshrc", "~/.zshrc") | |
# Doing this in .vimrc is unnecessarily hard. | |
Path("~/.vim-tmp").expanduser().mkdir(exist_ok=True) | |
for script in Path("bin").iterdir(): | |
link(script, "~"/script) | |
# For Gnome, set terminal preferences and remap caps lock. | |
if which("dconf"): | |
run("dconf load / < {}".format(here/"gnome-dconf-settings"), | |
shell=True, check=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
HERE=$(cd $(dirname "$BASH_SOURCE"); pwd) | |
if [[ "$HERE" != "$HOME/dotfiles" ]] ; then | |
echo 'can only be installed from ~/dotfiles' | |
exit 1 | |
fi | |
cd "$HERE" | |
peru sync | |
newshell=/bin/zsh | |
if [ $SHELL != $newshell ]; then | |
echo Switching default shell from $SHELL to $newshell... | |
chsh -s $newshell | |
fi | |
function link { | |
local src="$1" | |
local dest="$2" | |
mkdir -p $(dirname "$dest") | |
ln -sfn "$HERE/$src" "$dest" | |
} | |
link ackrc ~/.ackrc | |
link gitconfig ~/.gitconfig | |
link hgrc ~/.hgrc | |
link tmux.conf ~/.tmux.conf | |
link tmux.desktop ~/.local/share/applications/tmux.desktop | |
link vim ~/.vim | |
link vimrc ~/.vimrc | |
link zshrc ~/.zshrc | |
# Doing this in .vimrc is unnecessarily hard. | |
mkdir -p ~/.vim-tmp | |
for script in $(ls bin); do | |
link "bin/$script" ~/bin/"$script" | |
done | |
# For Gnome, set terminal preferences and remap caps lock. | |
if which dconf &> /dev/null ; then | |
dconf load / < $HERE/gnome-dconf-settings | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment