install-files: change to Python script; fix symlink creation
This commit is contained in:
parent
50c11a9acf
commit
3914f7d9cc
@ -1,23 +1,32 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env python
|
||||||
|
|
||||||
here="$(dirname $0)"
|
import os
|
||||||
|
import sys
|
||||||
|
from subprocess import Popen, PIPE
|
||||||
|
|
||||||
function install_file()
|
here = os.path.dirname(sys.argv[0])
|
||||||
{
|
if here.startswith('./'):
|
||||||
source="${here}/$1"
|
here = os.getcwd() + here[1:]
|
||||||
dest="${HOME}/$2"
|
|
||||||
if [ -e "$dest" ]; then
|
|
||||||
echo "Skipping $1"
|
|
||||||
else
|
|
||||||
echo "Installing $1"
|
|
||||||
mkdir -p $(dirname "$dest")
|
|
||||||
ln -s "$source" "$dest"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
install_file bash_aliases .bash_aliases
|
def install_file(src, dst):
|
||||||
install_file vimrc .vimrc
|
source = '%s/%s' % (here, src)
|
||||||
install_file inputrc .inputrc
|
dest = '%s/%s' % (os.environ['HOME'], dst)
|
||||||
install_file screenrc .screenrc
|
if os.path.exists(dest):
|
||||||
install_file ir_black.vim .vim/colors/ir_black.vim
|
sys.stdout.write('Skipping %s\n' % dst)
|
||||||
install_file gitignore .gitignore
|
else:
|
||||||
|
sys.stdout.write('Installing %s\n' % dst)
|
||||||
|
if not os.path.exists(os.path.dirname(dest)):
|
||||||
|
os.makedirs(os.path.dirname(dest))
|
||||||
|
Popen(['ln', '-s', source, dest]).wait()
|
||||||
|
|
||||||
|
files = [
|
||||||
|
('bash_aliases', '.bash_aliases'),
|
||||||
|
('vimrc', '.vimrc'),
|
||||||
|
('inputrc', '.inputrc'),
|
||||||
|
('screenrc', '.screenrc'),
|
||||||
|
('ir_black.vim', '.vim/colors/ir_black.vim'),
|
||||||
|
('gitignore', '.gitignore'),
|
||||||
|
]
|
||||||
|
|
||||||
|
for s, d in files:
|
||||||
|
install_file(s, d)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user