]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - setup.sh
tmux.conf: Use line continuation.
[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 # Create private temporary directory used by many tools (including GNU screen
26 # and tmux).
27 mkdir -p ~/.tmp
28 chmod 0700 ~/.tmp
29
30 # Generate ~/.less with lesskey.
31 lesskey lesskey
32 chmod 0600 ~/.less
33
34 # As screen-256color is not widely supported use it only on machines known to
35 # work.
36 generate cat screenrc .in
37 if [ $hostname != asp -a $hostname != systemofadown ]; then
38     sed 's/Enable 256 color/Disable 256 color/;
39          s/screen-256color/screen/' screenrc > screenrc.tmp
40     mv screenrc.tmp screenrc
41 fi
42 # Some options are only necessary when running as root. They are marked as
43 # "(ROOT)".
44 if [ x`id -u` != x0 ]; then
45     echo screenrc: removing root options
46     grep -v '(ROOT)' screenrc > screenrc.tmp
47     mv screenrc.tmp screenrc
48 fi
49 # I use some features of screen which are only in Git. Drop them on machines
50 # which have older versions. They are marked as "(GIT)".
51 if [ $hostname != asp -o x`id -u` = x0 ]; then
52     echo screenrc: removing Git features
53     grep -v '(GIT)' screenrc > screenrc.tmp
54     mv screenrc.tmp screenrc
55 fi
56 # Rxvt doesn't need the attrcolor "fix". As I prefer rxvt assume I use it when
57 # it's installed.
58 if installed rxvt; then
59     echo screenrc: removing attrcolor \"fix\"
60     sed 's/attrcolor b ".I"/#attrcolor b ".I"/' screenrc > screenrc.tmp
61     mv screenrc.tmp screenrc
62 fi
63 # Display current battery charge on computers with a battery. Necessary lines
64 # are marked as "(BATTERY)".
65 if [ ! -d /sys/class/power_supply/BAT0 ]; then
66     echo screenrc: removing battery display
67     grep -v '(BATTERY)' screenrc > screenrc.tmp
68     mv screenrc.tmp screenrc
69 fi
70
71 # Htop overwrites the comments in its configuration file.
72 generate cat htoprc .in
73
74 # Link setup for shells.
75 link shell ~/.shell
76 link bash ~/.bash
77 link bash/rc ~/.bashrc
78 link bash/profile ~/.bash_profile
79 link bash/logout ~/.bash_logout
80 if installed csh; then
81     link csh/rc ~/.cshrc
82 fi
83 link zsh ~/.zsh
84 link zsh/env ~/.zshenv
85 link zsh/rc ~/.zshrc
86 link zsh/logout ~/.zlogout
87
88 # Link setup for additional files.
89 link lessfilter ~/.lessfilter
90 if installed colordiff; then
91     link colordiffrc ~/.colordiffrc
92 fi
93 link inputrc ~/.inputrc
94 link screenrc ~/.screenrc
95 if installed tmux; then
96     generate perl tmux.conf ./bin/remove-continuation.pl
97     link tmux.conf ~/.tmux.conf
98 fi
99 if installed htop; then
100     link htoprc ~/.htoprc
101 fi
102
103 # Create rlwrap history directory.
104 mkdir -p shell/rlwrap