Navigation Menu

Skip to content

Commit

Permalink
Initial Commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
rkoesters committed Oct 30, 2013
0 parents commit 1839a5b
Show file tree
Hide file tree
Showing 13 changed files with 274 additions and 0 deletions.
110 changes: 110 additions & 0 deletions INSTALL
@@ -0,0 +1,110 @@
#!/bin/sh
set -e

usage () {
echo "Usage: $0 [OPTIONS]"
echo
echo "Options:"
echo " -c, --check Check that all source files exist. Implies -n."
echo " -n, --noexec Do not execute commands."
echo " -v, --verbose Print each command as they are executed."
echo " -h, --help Display help message and exit."
}

# Output arguments as semicolon separated list.
join () {
string="$1"
shift
for i in "$@"; do
string="$string:$i"
done
echo "$string"
}

# Run the given command.
cmd () {
if [ "$verbose" = "1" ]; then
echo "$@"
fi

if [ "$noexec" != "1" ]; then
"$@"
fi
}


# Parse arguments.
while [ $# -gt 0 ]; do
case $1 in
-c|--check)
check=1
;;
-n|--noexec)
noexec=1
;;
-v|--verbose)
verbose=1
;;
-h|--help)
usage >&2
exit 0
;;
*)
echo "unknown option: $1" >&2
usage >&2
exit 1
;;
esac
shift
done

# Create list of directories that will be created.
dirs=`join \
config \
config/git \
config/sh \
config/sh/shrc.d \
vim \
vim/backup \
vim/tmp \
`

# Create list of files that will be installed.
files=`join \
config/git/config \
config/sh/shrc \
config/sh/shrc.d/alias.sh \
config/sh/shrc.d/defaults.sh \
config/sh/shrc.d/functions.sh \
config/sh/shrc.d/prompt.sh \
config/sh/shrc.d/prompt_command.sh \
config/sh/shrc.d/title.sh \
config/sh/shrc.d/vars.sh \
profile \
vimrc \
`

# Check if all source files exist.
if [ "$check" = "1" ]; then
status=0
IFS=':'
for i in $files; do
if [ ! -f "$i" ]; then
echo "missing file: $i" >&2
status=1
fi
done
exit $status
fi

# Create directories.
IFS=':'
for i in $dirs; do
cmd mkdir "$HOME/.$i"
done

# Install files.
IFS=':'
for i in $files; do
cmd cp "$i" "$HOME/.$i"
done
1 change: 1 addition & 0 deletions README
@@ -0,0 +1 @@
My configuration files.
7 changes: 7 additions & 0 deletions config/git/config
@@ -0,0 +1,7 @@
[user]
name = Ryan Koesters
email = rmkoesters@gmail.com
[help]
format = html
[push]
default = simple
10 changes: 10 additions & 0 deletions config/sh/shrc
@@ -0,0 +1,10 @@
#!/bin/sh
# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# Source shell scripts in 'shrc.d/'.
for i in `dirname $ENV`/shrc.d/*.sh
do
. $i
done
unset i
9 changes: 9 additions & 0 deletions config/sh/shrc.d/alias.sh
@@ -0,0 +1,9 @@
case $termprog in
9term|win)
alias ls='ls -F'
;;
*)
alias ls='ls -p --color=auto'
alias tree='_tree'
;;
esac
44 changes: 44 additions & 0 deletions config/sh/shrc.d/defaults.sh
@@ -0,0 +1,44 @@
# Check if the executable exists.
check_exist () {
which "$@" >/dev/null 2>/dev/null
return $?
}

# Find which web browser to use.
#if check_exist chromium-browser
#then
# BROWSER=chromium-browser
#else
# BROWSER=firefox
#fi
BROWSER=firefox

# Find EDITOR and PAGER.
case $termprog in
9term|win)
PAGER=cat
EDITOR=E
;;
*)
# Find the text editor.
if check_exist vim
then
EDITOR=vim
elif check_exist vi
then
EDITOR=vi
else
EDITOR=ed
fi

# Find the pager.
if check_exist less
then
PAGER=less
else
PAGER=more
fi
;;
esac

export BROWSER EDITOR PAGER
8 changes: 8 additions & 0 deletions config/sh/shrc.d/functions.sh
@@ -0,0 +1,8 @@
_tree () {
if [ -t 1 ]
then
command tree -C "$@"
else
command tree "$@"
fi
}
10 changes: 10 additions & 0 deletions config/sh/shrc.d/prompt.sh
@@ -0,0 +1,10 @@
PS1='$ '
PS2='> '
PS4='+ '

if [ x"$BASH_VERSION" = x"" ]
then
PS1='`prompt_command`$ '
else
PROMPT_COMMAND="prompt_command"
fi
23 changes: 23 additions & 0 deletions config/sh/shrc.d/prompt_command.sh
@@ -0,0 +1,23 @@
# Runs before every prompt.
prompt_command () {
case $TERM in
xterm*|rxvt*|stterm*)
set_xterm_title "`get_title_string`"
;;
9term|dumb)
# We will get an error if we ever actually use a
# dumb terminal, but I think it is safe to assume
# that it is Acme or 9term.
awd
;;
*)
;;
esac
}

# Get string used for terminal title.
get_title_string () {
pwd=`pwd | sed "s#$HOME#~#"`

echo "$USER@$HOSTNAME:$pwd"
}
4 changes: 4 additions & 0 deletions config/sh/shrc.d/title.sh
@@ -0,0 +1,4 @@
# Override the xterm window title.
set_xterm_title () {
printf '\033]0;%s\007' "$@"
}
7 changes: 7 additions & 0 deletions config/sh/shrc.d/vars.sh
@@ -0,0 +1,7 @@
HOSTNAME="`hostname | sed 's/\..*$//'`"
LC_COLLATE="C"
USER="`whoami`"
tabstop="8"
textwidth=72

export HOSTNAME LC_COLLATE USER tabstop textwidth
14 changes: 14 additions & 0 deletions profile
@@ -0,0 +1,14 @@
export ENV="$HOME/.config/sh/shrc"
export GOPATH="$HOME/go"
export PLAN9="/opt/plan9port"
export PATH="$HOME/.local/bin:$PATH:$GOPATH/bin"

if [ -n "$DISPLAY" ]
then
9 plumber
fi

if [ x"$BASH_VERSION" != x"" ]
then
. $ENV
fi
27 changes: 27 additions & 0 deletions vimrc
@@ -0,0 +1,27 @@
set nocompatible
set encoding=utf8

" General settings.
set autoindent
set background=dark
set formatoptions=tcqrnj
set noexpandtab
set nowrap
set scrolloff=2
set spell
set title

" These options use environmental variables.
let &colorcolumn=$textwidth+1
let &tabstop=$tabstop
let &textwidth=$textwidth

" Backup.
set backup
set backupdir=~/.vim/backup
set directory=~/.vim/tmp

" Syntax
syntax on
au BufRead,BufNewFile *.md set filetype=markdown
au BufRead,BufNewFile *.vala,*.vapi setfiletype vala

0 comments on commit 1839a5b

Please sign in to comment.