-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.py
executable file
·88 lines (74 loc) · 2.3 KB
/
install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import subprocess
import os
DOTFILES_DIR = os.path.expanduser('~/Source/dotfiles/')
SYMLINKS = (
('.aliases', '~/.aliases'),
# Bash - disabled due to switch to zsh
# but kept around for posterity.
# ('.bashrc', '~/.bashrc'),
# ('.bash_profile', '~/.bash_profile'),
# ('.bash_prompt', '~/.bash_prompt'),
# Zsh
('.zshrc', '~/.zshrc'),
# Shell bits
('.path', '~/.path'),
('.inputrc', '~/.inputrc'),
('.hushlogin', '~/.hushlogin'),
# Atuin
('.config/atuin/config.toml', '~/.config/atuin/config.toml'),
# Ag - silver searcher.
('.agignore', '~/.agignore'),
# Git
('.gitconfig', '~/.gitconfig'),
('.gitignore_', '~/.gitignore'),
('.git_commit_msg.txt', '~/.git_commit_msg.txt'),
# Mercurial
('.hgext', '~/.hgext'),
('.hgrc', '~/.hgrc'),
# Vim
('.vimrc', '~/.vimrc'),
('.vim', '~/.vim'),
# Emacs
('.spacemacs', '~/.spacemacs'),
# Python
('.config/flake8', '~/.config/flake8'),
)
POST_COMMANDS = (
# Install zplug
'curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh',
# Install Vim packages via vundle.
'vim +PluginInstall +qall',
)
def underline(title):
""" Underlines a string """
return "{0}\n{1}\n".format(title, len(title) * '=')
def install_dotfiles():
print(underline('Creating symlinks'))
for orig_loc, symlink in SYMLINKS:
symlink = os.path.expanduser(symlink)
symlink_dir = os.path.dirname(symlink)
if not os.path.exists(symlink_dir):
os.makedirs(symlink_dir)
orig_loc = '{}{}'.format(DOTFILES_DIR, orig_loc)
create_symlink(orig_loc, symlink)
print ("")
def create_symlink(orig_loc, symlink):
print('Symlink: {}'.format(symlink))
if os.path.exists(symlink):
print('✘ Failed: path exists.')
return
os.symlink(orig_loc, symlink)
print ('✔ Created.')
def run_post_install_commands():
print(underline('Running install commands'))
for command in POST_COMMANDS:
print('Running: {}'.format(command))
subprocess.call(command, shell=True)
return
if __name__ == "__main__":
print('')
install_dotfiles()
run_post_install_commands()
print('\nDone!')