Newer
Older
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
import utils
def setup(interactive=True):
cmds = [
'apt-get update',
'apt-get install --yes make ipython ipython3 vim netcat git htop iotop bmon host lm-sensors munin munin-node pciutils ntp nfs-client smartmontools pwgen ntpdate dialog',
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
'[ -f ~/.vimrc ] || echo "color ron" > ~/.vimrc',
]
utils.run_commands(cmds)
# Add settings in bashrc
lines = '''
# Colors
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# PS
PS1='${debian_chroot:+($debian_chroot)}\\[\\033[01;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ '
# ls
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# system
alias lskernels='dpkg --get-selections | grep linux'
alias lspackages='dpkg --get-selections'
alias swapclear='sudo swapoff -a && sudo swapon -a'
alias full-upgrade='sudo apt-get update && sudo apt-get dist-upgrade -y'
alias aptud='sudo apt-get update'
alias aptug='sudo apt-get upgrade'
# python
alias rmpyc='find . -name *.pyc -type f -delete && find . -name __pycache__ -type d -delete'
'''
bashrc_path = os.path.expanduser('~/.bashrc')
bashrc = ''
if os.path.exists(bashrc_path):
with open(bashrc_path, 'r') as fd:
bashrc = fd.read()
new_bashrc = bashrc.replace('#force_color_prompt=yes', 'force_color_prompt=yes')
for line in lines.split('\n'):
line = line.strip()
if '=' in line:
name = line.split('=')[0] + '='
if name not in new_bashrc:
new_bashrc += '\n' + line
if new_bashrc != bashrc:
new_bashrc += '\n'
with open(bashrc_path, 'w') as fd:
fd.write(new_bashrc)
utils.log('bashrc file updated: %s' % bashrc_path)
utils.log('bashrc file up to date.')