Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
esert committed Jun 21, 2012
0 parents commit b9eadf1
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .emacs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
(setq-default
; no startup screen
inhibit-startup-screen t

; no backup/auto-save, bad idea
backup-inhibited t
auto-save-default nil
make-backup-files nil

show-trailing-whitespace t

; newline to end of buffer before save
require-final-newline t)

; no menu bar
(menu-bar-mode -1)

; y/n instead of yes/no
(fset 'yes-or-no-p 'y-or-n-p)

; use one of these names for shell buffer
(setq shell-names '("s0" "s1" "s2" "s3" "s4" "s5" "s6" "s7" "s8" "s9"))
(defun get-shell-name (names)
(if names
(if (get-buffer (car names))
(get-shell-name (cdr names))
(car names))
nil))
(defun rename-shell-buffer ()
(let ((shell-name (get-shell-name shell-names)))
(if shell-name
(rename-buffer shell-name)
(message "No more free shell names, use M-x rename-buffer"))))
(add-hook 'shell-mode-hook 'rename-shell-buffer)

; start shell if no file's given
(unless (> (length command-line-args) 1)
(shell))
56 changes: 56 additions & 0 deletions .profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# return if not interactive
[ -z "$PS1" ] && return

# .bash_history related
HISTSIZE=5000
HISTFILESIZE=5000

# don't just quit if background jobs exist
shopt -s checkjobs
# check window size
shopt -s checkwinsize
# append to history
shopt -s histappend

# machine dependent
case `uname -s` in
Darwin)
alias ls='ls -G'
alias ll='ls -AlG'
alias la='ls -AG'
# bash completion
[ -f /opt/local/etc/bash_completion ] && . /opt/local/etc/bash_completion
# set path
PATH=.:/opt/local/bin:/opt/local/sbin:$PATH
# gui alert
function alert {
echo $*
osascript -e 'tell app "System Events" to display dialog "'"$*"'"'
}
;;
Linux)
alias ls='ls --color=auto'
alias ll='ls -Al --color=auto'
alias la='ls -A --color=auto'
[ -f /etc/bash_completion ] && . /etc/bash_completion
PATH=.:$PATH
alias alert='xmessage'
;;
*)
echo "I don't know what to do with this machine!"
;;
esac

# alias
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias emacs='emacs -nw'
alias ssh='ssh -X'

# change prompt
source ~/.prompt

export PATH
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
59 changes: 59 additions & 0 deletions .prompt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
function my_timer_start {
my_timer=${my_timer:-$SECONDS}
}

function my_timer_stop {
my_time=$(( $SECONDS - $my_timer ))
if (( $my_time > 59 )); then
local s=$(( $my_time % 60 ))
local m=$(( $my_time / 60 ))
if (( $m > 59 )); then
local m=$(( $m % 60 ))
local h=$(( $my_time / 3600 ))
my_time=$h':'$m':'$s
else
my_time=$m':'$s
fi
fi
unset my_timer
}

function my_prompt {
local exit_status="$?"
my_timer_stop
local default_user="esert";
local RED="\[\033[1;31m\]"
local OFF="\[\033[0m\]"
if [ "$USER" != "$default_user" ]; then
if [ "$exit_status" != "0" ]; then
if [ "$my_time" != "0" ]; then
PS1="${RED}USER: \u${OFF}\n${RED}ERROR: ${exit_status}${OFF}\n\h:\w[$my_time]\$ "
else
PS1="${RED}USER: \u${OFF}\n${RED}ERROR: ${exit_status}${OFF}\n\h:\w\$ "
fi
else
if [ "$my_time" != "0" ]; then
PS1="${RED}USER: \u${OFF}\n\h:\w[$my_time]\$ "
else
PS1="${RED}USER: \u${OFF}\n\h:\w\$ "
fi
fi
else
if [ "$exit_status" != "0" ]; then
if [ "$my_time" != "0" ]; then
PS1="${RED}ERROR: ${exit_status}${OFF}\n\h:\w[$my_time]\$ "
else
PS1="${RED}ERROR: ${exit_status}${OFF}\n\h:\w\$ "
fi
else
if [ "$my_time" != "0" ]; then
PS1="\h:\w[$my_time]\$ "
else
PS1="\h:\w\$ "
fi
fi
fi
}

trap 'my_timer_start' DEBUG
PROMPT_COMMAND=my_prompt
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
install:
cd; rm -rf .profile .bash_profile .bashrc .prompt .emacs .emacs.d
cp .profile .prompt .emacs ~
cd; ln -s .profile .bash_profile; ln -s .profile .bashrc
2 changes: 2 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Save your .profile .bash_profile .bashrc .prompt .emacs .emacs.d
before running make.

0 comments on commit b9eadf1

Please sign in to comment.