]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - setup.sh
*: License under GPL v3+.
[config/dotfiles.git] / setup.sh
1 #!/bin/sh
2
3 # Setup script for shell configuration files.
4
5 # Copyright (C) 2011-2012  Simon Ruderich
6 #
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20
21 . ../lib.sh
22
23 hostname=`hostname`
24
25 # Generate ~/.less with lesskey.
26 lesskey lesskey
27 chmod 0600 ~/.less
28
29 # As screen-256color is not widely supported use it only on machines known to
30 # work.
31 generate cat screenrc .in
32 if [ $hostname != asp -a $hostname != systemofadown ]; then
33     sed 's/Enable 256 color/Disable 256 color/;
34          s/screen-256color/screen/' screenrc > screenrc.tmp
35     mv screenrc.tmp screenrc
36 fi
37 # Some options are only necessary when running as root. They are marked as
38 # "(ROOT)".
39 if [ x`id -u` != x0 ]; then
40     echo screenrc: removing root options
41     grep -v '(ROOT)' screenrc > screenrc.tmp
42     mv screenrc.tmp screenrc
43 fi
44 # I use some features of screen which are only in Git. Drop them on machines
45 # which have older versions. They are marked as "(GIT)".
46 if [ $hostname != asp -o x`id -u` = x0 ]; then
47     echo screenrc: removing Git features
48     grep -v '(GIT)' screenrc > screenrc.tmp
49     mv screenrc.tmp screenrc
50 fi
51 # Rxvt doesn't need the attrcolor "fix". As I prefer rxvt assume I use it when
52 # it's installed.
53 if installed rxvt; then
54     echo screenrc: removing attrcolor \"fix\"
55     sed 's/attrcolor b ".I"/#attrcolor b ".I"/' screenrc > screenrc.tmp
56     mv screenrc.tmp screenrc
57 fi
58 # Display current battery charge on computers with a battery. Necessary lines
59 # are marked as "(BATTERY)".
60 if [ ! -d /sys/class/power_supply/BAT0 ]; then
61     echo screenrc: removing battery display
62     grep -v '(BATTERY)' screenrc > screenrc.tmp
63     mv screenrc.tmp screenrc
64 fi
65
66 # Link setup for shells.
67 link shell ~/.shell
68 link bash ~/.bash
69 link bash/rc ~/.bashrc
70 link bash/profile ~/.bash_profile
71 link bash/logout ~/.bash_logout
72 if installed csh; then
73     link csh/rc ~/.cshrc
74 fi
75 link zsh ~/.zsh
76 link zsh/env ~/.zshenv
77 link zsh/rc ~/.zshrc
78 link zsh/logout ~/.zlogout
79
80 # Link setup for additional files.
81 link lessfilter ~/.lessfilter
82 if installed colordiff; then
83     link colordiffrc ~/.colordiffrc
84 fi
85 link inputrc ~/.inputrc
86 link screenrc ~/.screenrc
87 if installed tmux; then
88     link tmux.conf ~/.tmux.conf
89 fi
90
91 # Create rlwrap history directory.
92 mkdir -p shell/rlwrap