diff --git a/completions/_rvm b/completions/_rvm new file mode 100644 index 000000000..5be28a358 --- /dev/null +++ b/completions/_rvm @@ -0,0 +1,72 @@ +#compdef rvm + +local curcontext="$curcontext" state line cmds ret=1 + +_arguments -C \ + '(- 1 *)'{-v,--version}'[display version information]' \ + '(-l|--level)'{-l,--level}'+[patch level to use with rvm use / install]:number' \ + '(--prefix)--prefix[path for all rvm files (~/.rvm/), with trailing slash!]:path:_files' \ + '(--bin)--bin[path for binaries to be placed (~/.rvm/bin/)]:path:_files' \ + '(--source)--source[src directory to use (~/.rvm/src/)]:path:_files' \ + '(--archives)--archives[directory for downladed files (~/.rvm/archives/)]:path:_files' \ + '-S[Specify a script file to attempt to load and run (rubydo)]:file:_files' \ + '-e[Execute code from the command line]:code' \ + '(-G)-G[root gem path to use]:path:_files' \ + '(--gems)--gems[Used to set the gems_flag, use with remove to remove gems]' \ + '(--archive)--archive[Used to set the archive_flag, use with remove to remove archive]' \ + '(--patch)--patch[With MRI Rubies you may specify one or more full paths to patches]' \ + '(-C|--configure)'{-C,--configure}'=[custom configure options]' \ + '(--nice)--nice[process niceness (for slow computers, default 0)]:number' \ + '(--ree)--ree-options[Options passed directly to ree ./installer on the command line]:options' \ + '(--head)--head[with update, updates rvm to git head version]' \ + '(--rubygems)--rubygems[with update, updates rubygems for selected ruby]' \ + '(--default)--default[with ruby select, sets a default ruby for new shells]' \ + '(--debug)--debug[Toggle debug mode on for very verbose output]' \ + '(--trace)--trace[Toggle trace mode on to see EVERYTHING rvm is doing]' \ + '(--force)--force[Force install, removes old install & source before install]' \ + '(--summary)--summary[Used with rubydo to print out a summary of the commands run]' \ + '(--latest)--latest[with gemset --dump skips version strings for latest gem]' \ + '(--gems)--gems[with uninstall/remove removes gems with the interpreter]' \ + '(--docs)--docs[with install, attempt to generate ri after installation]' \ + '(--reconfigure)--reconfigure[Force ./configure on install even if Makefile already exists]' \ + '1: :->cmds' \ + '*: :->args' && ret=0 + +case $state in + cmds) + cmds=( ${(f)"$(_call_program commands rvm help 2> /dev/null | sed -e '/^Action/,/^Implementation/!d; / - /!d; s/^[ *]*\([^ ]*\) *\- *\(.*\)/\1:\2/')"} ) + cmds+=( $(rvm list strings) ) + _describe -t commands 'rvm command' cmds && ret=0 + ;; + args) + case $line[1] in + (use|uninstall|remove|list) + _values -S , 'rubies' $(rvm list strings | sed -e 's/ruby-\([^) ]*\)-\([^) ]*\)/ruby-\1-\2 \1-\2 \1/g') default system && ret=0 + ;; + (install|fetch) + _values -S , 'rubies' $(rvm list known_strings) && ret=0 + ;; + gemset) + if (( CURRENT == 3 )); then + _values 'gemset_commands' $(rvm gemset | sed -e '/create/!d; s/^.*[{]\(.*\)[}].*$/\1/; s/,/ /g') + else + _values -S , 'gemsets' $(rvm gemset list | \grep -v gemset 2>/dev/null) + fi + ret=0 + ;; + package) + if (( CURRENT == 3 )); then + _values 'package_commands' $(rvm package | sed -e '/Usage/!d; s/^.*[{]\(.*\)[}] [{].*$/\1/; s/,/ /g') + else + _values 'packages' $(rvm package | sed -e '/Usage/!d; s/^.*[}] [{]\(.*\)[}].*$/\1/; s/,/ /g') + fi + ret=0 + ;; + *) + (( ret )) && _message 'no more arguments' + ;; + esac + ;; +esac + +return ret diff --git a/custom/bindings.zsh b/custom/bindings.zsh new file mode 100644 index 000000000..208b9d035 --- /dev/null +++ b/custom/bindings.zsh @@ -0,0 +1,2 @@ +# Alt-Enter to run in background +bindkey -s "^[\r" "^e &\r" diff --git a/custom/screen.zsh b/custom/screen.zsh new file mode 100644 index 000000000..67748ba03 --- /dev/null +++ b/custom/screen.zsh @@ -0,0 +1,14 @@ +# don't rename screen window +case "$TERM" in + screen*) + preexec () { + local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} + # echo -ne "\ek$CMD\e\\" + print -Pn "\e]0;%n@%m: $1\a" # xterm + } + precmd () { + # echo -ne "\ekzsh\e\\" + print -Pn "\e]0;%n@%m: %~\a" # xterm + } + ;; +esac diff --git a/lib/git.zsh b/lib/git.zsh index ce4de5598..802e85221 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -1,6 +1,6 @@ # get the name of the branch we are on function git_prompt_info() { - ref=$(git symbolic-ref HEAD 2> /dev/null) || return + ref=$(git rev-parse --abbrev-ref HEAD 2> /dev/null) || return echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" } diff --git a/lib/grep.zsh b/lib/grep.zsh index 93c4270b6..374279a69 100644 --- a/lib/grep.zsh +++ b/lib/grep.zsh @@ -3,4 +3,4 @@ # Examples: http://rubyurl.com/ZXv # export GREP_OPTIONS='--color=auto' -export GREP_COLOR='1;32' \ No newline at end of file +export GREP_COLOR='1;32' diff --git a/lib/history.zsh b/lib/history.zsh index ca6f57079..6b9b0d5b2 100644 --- a/lib/history.zsh +++ b/lib/history.zsh @@ -4,7 +4,7 @@ HISTSIZE=10000 SAVEHIST=10000 setopt hist_ignore_dups # ignore duplication command history list -setopt share_history # share command history data +#setopt share_history # share command history data setopt hist_verify setopt inc_append_history diff --git a/lib/rvm.zsh b/lib/rvm.zsh index 597be1b33..e1ac9e7bb 100644 --- a/lib/rvm.zsh +++ b/lib/rvm.zsh @@ -3,5 +3,3 @@ function rvm_prompt_info() { ruby_version=$(~/.rvm/bin/rvm-prompt 2> /dev/null) || return echo "($ruby_version)" } - - diff --git a/plugins/resty/resty.plugin.zsh b/plugins/resty/resty.plugin.zsh new file mode 100644 index 000000000..61b83260a --- /dev/null +++ b/plugins/resty/resty.plugin.zsh @@ -0,0 +1,104 @@ +# +# resty - A tiny command line REST interface for bash and zsh. +# +# Fork me on github: +# http://github.com/micha/resty +# +# Author: +# Micha Niskin +# Copyright 2009, no rights reserved. +# + +export _resty_host="" +export _resty_path="" + +function resty() { + local confdir host cookies method h2t editor domain _path opt dat res ret out err verbose raw i d tmpf args2 + + confdir="${HOME}/.resty" + host="${confdir}/host" + cookies="$confdir/c" + method="$1"; [[ $# > 0 ]] && shift + h2t=$((which lynx >/dev/null && echo lynx -stdin -dump) \ + || which html2text || which cat) + editor=$(which "$EDITOR" || which vim || echo "vi") + + [ -d "$cookies" ] || (mkdir -p "$cookies"; echo "http://localhost*" > "$host") + [ -n "$1" ] && [ "${1#/}" != "$1" ] \ + && _path=$(echo "$1"|sed 's/%/%25/g;s/\[/%5B/g;s/\]/%5D/g;s/|/%7C/g;s/\$/%24/g;s/&/%26/g;s/+/%2B/g;s/,/%2C/g;s/:/%3A/g;s/;/%3B/g;s/=/%3D/g;s/?/%3F/g;s/@/%40/g;s/ /%20/g;s/#/%23/g;s/{/%7B/g;s/}/%7D/g;s/\\/%5C/g;s/\^/%5E/g;s/~/%7E/g;s/`/%60/g') && shift + + for i in "$@"; do + ([ "$i" = "--verbose" ] || echo "$i" | grep -q '^-[a-zA-Z]*v[a-zA-Z]*$') \ + && verbose="yes" + done + + [ -z "$_resty_host" ] && _resty_host=$(cat "$host" 2>/dev/null) + [ -z "$method" ] && echo "$_resty_host" && return + [ -n "$_path" ] && _resty_path=$_path + domain=$(echo -n "$_resty_host" \ + |perl -ane '/^https?:\/\/([^\/\*]+)/; print $1') + _path="${_resty_host//\*/$_resty_path}" + + case "$method" in + GET|DELETE|POST|PUT) + dat=$( ( [ "${method#P}" != "$method" ] \ + && ( ( [ -n "$1" ] && [ "${1#-}" = "$1" ] && echo "$1") \ + || echo "@-") ) || echo) + if [ "${method#P}" != "$method" ] && [ "$1" = "-V" ]; then + tmpf=$(mktemp /tmp/resty.XXXXXX) + cat > $tmpf + (exec < /dev/tty; "$editor" $tmpf) + dat=$(cat $tmpf) + rm -f $tmpf + fi + [ -n "$dat" ] && [ "$dat" != "@-" ] && shift + [ "$1" = "-Z" ] && raw="yes" && shift + [ -n "$dat" ] && opt="--data-binary" + eval "args2=( $(cat "$confdir/$domain" 2>/dev/null |sed 's/^ *//' |grep ^$method |cut -b $((${#method}+2))-) )" + res=$((((curl -sLv $opt "$dat" -X $method \ + -b "$cookies/$domain" -c "$cookies/$domain" \ + "${args2[@]}" "$@" "$_path" \ + |sed 's/^/OUT /' && echo) 3>&2 2>&1 1>&3) \ + |sed 's/^/ERR /' && echo) 2>&1) + out=$(echo "$res" |sed '/^OUT /s/^....//p; d') + err=$(echo "$res" |sed '/^ERR /s/^....//p; d') + ret=$(echo "$err" |sed \ + '/^.*HTTP\/1\.[01] [0-9][0-9][0-9]/s/.*\([0-9]\)[0-9][0-9].*/\1/p; d' \ + | tail -n1) + [ -n "$err" -a -n "$verbose" ] && echo "$err" 1>&2 + echo "$err" | grep -qi '^< \s*Content-Type: *text/html' \ + && [ -z "$raw" ] && d=$h2t || d=cat + [ -n "$out" ] && out=$(echo "$out" |eval "$d") + [ "$d" != "${d##lynx}" ] && out=$(echo "$out" |perl -e "\$host='$(echo "$_resty_host" |sed 's/^\(https*:\/\/[^\/*]*\).*$/\1/')';" -e '@a=<>; $s=0; foreach (reverse(@a)) { if ($_ =~ /^References$/) { $s++; } unless ($s>0) { s/^\s+[0-9]+\. //; s/^file:\/\/localhost/$host/; } push(@ret,$_); } print(join("",reverse(@ret)))') + if [ "$ret" != "2" ]; then + [ -n "$out" ] && echo "$out" 1>&2 + return $ret + else + [ -n "$out" ] && echo "$out" + fi + ;; + http://*|https://*) + echo "$method" |grep -q '\*' || method="${method}*" + (echo "$method" |tee "$host") |cat 1>&2 && _resty_host="$method" + ;; + *) + resty "http://$method" + ;; + esac +} + +function GET() { + resty GET "$@" +} + +function POST() { + resty POST "$@" +} + +function PUT() { + resty PUT "$@" +} + +function DELETE() { + resty DELETE "$@" +} \ No newline at end of file diff --git a/plugins/zendesk/zendesk.plugin.zsh b/plugins/zendesk/zendesk.plugin.zsh new file mode 100644 index 000000000..661cf5eac --- /dev/null +++ b/plugins/zendesk/zendesk.plugin.zsh @@ -0,0 +1,16 @@ +# To use: add a .zendesk file into your directory with the URL to the +# individual project. For example: +# https://help.trabian.com/tickets/8994 +open_zendesk_ticket () { + if [ ! -f ~/.zendesk-url ]; then + echo "There is no .zendesk file in the home directory..." + return 0; + else + zendesk_url=$(cat ~/.zendesk-url); + echo "Opening ticket #$1"; + `open $zendesk_url/tickets/$1`; + fi +} + +alias zo='open_zendesk_ticket' +alias ticket='open_zendesk_ticket' diff --git a/themes/robbyrussell.zsh-theme b/themes/robbyrussell.zsh-theme index 7b524e82d..fdb49004d 100644 --- a/themes/robbyrussell.zsh-theme +++ b/themes/robbyrussell.zsh-theme @@ -1,6 +1,6 @@ -PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' +PROMPT='%{$fg_bold[grey]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' -ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}" +ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[grey]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}" ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})" diff --git a/tools/uninstall.sh b/tools/uninstall.sh index 8ff583322..9da5feff4 100644 --- a/tools/uninstall.sh +++ b/tools/uninstall.sh @@ -17,4 +17,4 @@ else source /etc/profile fi -echo "Thanks for trying out Oh My Zsh. It's been uninstalled." \ No newline at end of file +echo "Thanks for trying out Oh My Zsh. It's been uninstalled."