Welcome to MekTrix 4.0

Aka Shish’s Place of Stuff

SLEK

Part one of some notes on automation:

Having tired of keeping ~20 shell accounts up to date with my preferred settings, I made a script to do it. Snippets which other people may find useful are:

Only doing things if an app is installed:

is_installed() {
    if type -p $1 > /dev/null ; then
        return 0
    else
        return 1
    fi
}

if is_installed mplayer ; then
    ... do mplayer specific things ...
fi

Outputting large amounts of text from the script into the config file:

cat > ~/.vimrc <<EOD
syntax enable
set autoindent
set autowrite
set nocompatible    " Use Vim defaults instead of 100% vi compatibility
set backspace=indent,eol,start  " more powerful backspacing
set ruler
set foldmethod=marker
if v:version >= 700
    set spelllang=en_gb
    set spellfile=~/.vimspell.en_gb.add
    set spellfile=~/.vimspell.add
endif
EOD

cat > ~/.inputrc <<EOD
"\e[A": history-search-backward
"\e[B": history-search-forward

set completion-ignore-case On
#set editing-mode vi
set mark-symlinked-directories On
EOD

cat > ~/.bash_logout <<EOD
#!/bin/bash

if [ "\$SHLVL" = 1 ]; then
    [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi
EOD
chmod +x ~/.bash_logout

Now using those, I have all my important settings stored in one shell script. In order to push settings to another host, I can run “cat slek2.sh | ssh user@host.com”, which doesn’t even create any temporary files on the other side of the connection \o/

(Note: the post title, and the script, are called “slek”, which was originally a typo on “skel”, but then got made into “shish’s linux enhancement kit”. Though it’s also tested and working fine on solaris…)


Leave a Reply