Skip to content

Commit

Permalink
Make the zsh user config not quite so crazy.
Browse files Browse the repository at this point in the history
Move my stuff away from the module and into users::mythmon
  • Loading branch information
mythmon committed Apr 6, 2012
1 parent e785419 commit 7153cf9
Show file tree
Hide file tree
Showing 11 changed files with 176 additions and 72 deletions.
81 changes: 75 additions & 6 deletions modules/users/manifests/mythmon.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class users::mythmon {
$username = "mythmon"
$home = "/home/mythmon"

include zsh

Expand All @@ -26,18 +27,86 @@
group => "users";
}

os::user_config { "${username}": }
conky::user_config { "${username}": }
openbox::user_config { "${username}": }
ruby::dev::user_config { "${username}": }

vim::user_config { "${username}":
template => "users/mythmon/vimrc.erb",
pathogen => true,
}

git::user_config { "${username}":
template => "users/mythmon/gitconfig.erb",
}
zsh::user_config { "${username}":
template => "users/mythmon/zshrc.erb"
}

os::user_config { "${username}": }
zsh::user_config { "${username}": }
conky::user_config { "${username}": }
openbox::user_config { "${username}": }
ruby::dev::user_config { "${username}": }

@file {
"${username}_zshd":
path => "${home}/.zshrc.d",
tag => "zsh",
owner => "${username}",
group => "users",
ensure => directory;

"${username}-func":
path => "${home}/.zshrc.d/00_func",
content => template("users/mythmon/zsh/00_func.erb"),
tag => "zsh",
owner => "${username}",
group => "users",
ensure => present;
"${username}-01_hash_color":
path => "${home}/.zshrc.d/01_hash_color",
content => template("users/mythmon/zsh/01_hash_color.erb"),
tag => "zsh",
owner => "${username}",
group => "users",
ensure => present;
"${username}-10_autoterm":
path => "${home}/.zshrc.d/10_autoterm",
content => template("users/mythmon/zsh/10_autoterm.erb"),
tag => "zsh",
owner => "${username}",
group => "users",
ensure => present;
"${username}-20_auto_ls":
path => "${home}/.zshrc.d/20_auto_ls",
content => template("users/mythmon/zsh/20_auto_ls.erb"),
tag => "zsh",
owner => "${username}",
group => "users",
ensure => present;
"${username}-50_git":
path => "${home}/.zshrc.d/50_git",
content => template("users/mythmon/zsh/50_git.erb"),
tag => "zsh",
owner => "${username}",
group => "users",
ensure => present;
"${username}-51_misc":
path => "${home}/.zshrc.d/51_misc",
content => template("users/mythmon/zsh/51_misc.erb"),
tag => "zsh",
owner => "${username}",
group => "users",
ensure => present;
"${username}-52_ssh":
path => "${home}/.zshrc.d/52_ssh",
content => template("users/mythmon/zsh/52_ssh.erb"),
tag => "zsh",
owner => "${username}",
group => "users",
ensure => present;
"${username}-90_prompt":
path => "${home}/.zshrc.d/90_prompt",
content => template("users/mythmon/zsh/90_prompt.erb"),
tag => "zsh",
owner => "${username}",
group => "users",
ensure => present;
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
98 changes: 98 additions & 0 deletions modules/users/templates/mythmon/zshrc.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# .zshrc
HISTFILE=$HOME/.zsh/history
HISTSIZE=10000
SAVEHIST=10000

setopt append_history # Append instead of overwrite
setopt notify # Notify on bad completion
setopt extended_history # Save times and runtimes in the history
setopt hist_ignore_dups # Ignore same command run twice+
setopt hist_reduce_blanks # " cd .. " -> "cd .."
setopt hist_no_functions # Don't remember functions
setopt nobeep # Death to the beep!

zstyle :compinstall filename '$HOME/.zshrc'

autoload -Uz compinit promptinit
compinit
promptinit
prompt walters

setopt extendedglob
bindkey -e emacs

# ---- This section is not right when viewed on github.com ----
# ---- As of Nov 9, 2010, there are symbols that get eaten ----
# ---- git clone the file and it will be correct. ----

# key bindings
# Home/End
bindkey "OH" beginning-of-line
bindkey "OF" end-of-line
# Delete
bindkey "[3~" delete-char
# Up will search with whatever is on the line so far
bindkey "\e[A" up-line-or-search
bindkey "\e[B" down-line-or-search
# Left/Right
bindkey "\e[D" backward-char
bindkey "\e[C" forward-char
# Alt-Left/Right
bindkey "" emacs-backward-word
bindkey "" emacs-forward-word

# Make alt-backspace / ctrl-arrows have saner "words" (ie: path pieces instead of full paths)
WORDCHARS=${WORDCHARS//[&=\/;!#%\{]}

rationalise-dot() {
if [[ $LBUFFER = *.. ]]; then
LBUFFER+=/../
elif [[ $LBUFFER = *../ ]]; then
LBUFFER+=../
else
LBUFFER+=.
fi
}
zle -N rationalise-dot
bindkey . rationalise-dot

# preexec hook shows command in title as it's running, and precmd sets it to
# something else when it's done. this should work with screen and
# gnome-terminal2/multi-gnome-terminal

case $TERM in
xterm*|screen*)
preexec () {
export CURRENTCMD="$1"
if [ x$WINDOW != x ]; then
print -Pn "\ek$1\e\\"
else
print -Pn "\e]0;$1\a"
fi
}
precmd () {
if [[ ! -z $CURRENTCMD ]]; then
if [ x$WINDOW != x ]; then
print -Pn "\ek($CURRENTCMD)\e\\"
else
print -Pn "\e]0;($CURRENTCMD)\a"
fi
fi
}
;;
esac

PATH="$HOME/bin:$PATH"

export EDITOR="vim"

alias ls='ls --color=if-tty --group-directories-first -hF'
alias rm='rm -r'
alias cp='cp -r'

# Include various sub-.zshrc files
# but don't include vim .swp files
for file in $(ls $HOME/.zshrc.d/* | grep -ve ".swp$" | grep -ve ".bak$")
do
source $file
done
69 changes: 3 additions & 66 deletions modules/zsh/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
ensure => latest,
}

File <| tag == "vim" |>
File <| tag == "zsh" |>
}

# config!
define zsh::user_config ($home="/home/${title}") {
define zsh::user_config ($home="/home/${title}", template="zsh/zshrc.erb") {

@file {
"${title}_zsh_dir":
Expand All @@ -16,72 +16,9 @@
owner => "${title}",
group => "users",
ensure => directory;
"${title}_zshd":
path => "${home}/.zshrc.d",
tag => "zsh",
owner => "${title}",
group => "users",
ensure => directory;

"${title}-zshrc":
path => "${home}/.zshrc",
content => template("zsh/zshrc.erb"),
tag => "zsh",
owner => "${title}",
group => "users",
ensure => present;
"${title}-func":
path => "${home}/.zshrc.d/00_func",
content => template("zsh/00_func.erb"),
tag => "zsh",
owner => "${title}",
group => "users",
ensure => present;
"${title}-01_hash_color":
path => "${home}/.zshrc.d/01_hash_color",
content => template("zsh/01_hash_color.erb"),
tag => "zsh",
owner => "${title}",
group => "users",
ensure => present;
"${title}-10_autoterm":
path => "${home}/.zshrc.d/10_autoterm",
content => template("zsh/10_autoterm.erb"),
tag => "zsh",
owner => "${title}",
group => "users",
ensure => present;
"${title}-20_auto_ls":
path => "${home}/.zshrc.d/20_auto_ls",
content => template("zsh/20_auto_ls.erb"),
tag => "zsh",
owner => "${title}",
group => "users",
ensure => present;
"${title}-50_git":
path => "${home}/.zshrc.d/50_git",
content => template("zsh/50_git.erb"),
tag => "zsh",
owner => "${title}",
group => "users",
ensure => present;
"${title}-51_misc":
path => "${home}/.zshrc.d/51_misc",
content => template("zsh/51_misc.erb"),
tag => "zsh",
owner => "${title}",
group => "users",
ensure => present;
"${title}-52_ssh":
path => "${home}/.zshrc.d/52_ssh",
content => template("zsh/52_ssh.erb"),
tag => "zsh",
owner => "${title}",
group => "users",
ensure => present;
"${title}-90_prompt":
path => "${home}/.zshrc.d/90_prompt",
content => template("zsh/90_prompt.erb"),
content => template("${template}"),
tag => "zsh",
owner => "${title}",
group => "users",
Expand Down

0 comments on commit 7153cf9

Please sign in to comment.