summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/key-bindings.zsh4
-rw-r--r--lib/termsupport.zsh5
-rw-r--r--plugins/debian/debian.plugin.zsh4
-rwxr-xr-xplugins/emacs/emacsclient.sh2
-rw-r--r--plugins/jsontools/README.md42
-rw-r--r--plugins/jsontools/jsontools.plugin.zsh27
-rw-r--r--plugins/pow/pow.plugin.zsh14
-rw-r--r--plugins/rake-fast/README.md23
-rw-r--r--plugins/rake-fast/rake-fast.plugin.zsh26
-rw-r--r--templates/zshrc.zsh-template26
10 files changed, 126 insertions, 47 deletions
diff --git a/lib/key-bindings.zsh b/lib/key-bindings.zsh
index 5f3f237c7..9063c6a18 100644
--- a/lib/key-bindings.zsh
+++ b/lib/key-bindings.zsh
@@ -46,8 +46,8 @@ bindkey ' ' magic-space # [Space] - do history exp
bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
-if [[ "${terminfo[kdch1]}" != "" ]]; then
- bindkey "${terminfo[kdch1]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards
+if [[ "${terminfo[kcbt]}" != "" ]]; then
+ bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards
fi
bindkey '^?' backward-delete-char # [Backspace] - delete backward
diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
index 5f2fe63d4..9c0a430fb 100644
--- a/lib/termsupport.zsh
+++ b/lib/termsupport.zsh
@@ -26,8 +26,11 @@ function omz_termsupport_precmd {
function omz_termsupport_preexec {
emulate -L zsh
setopt extended_glob
- local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
+
+ # cmd name only, or if this is sudo or ssh, the next cmd
+ local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]:gs/%/%%}
local LINE="${2:gs/%/%%}"
+
title '$CMD' '%100>...>$LINE%<<'
}
diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh
index 28dfb82a5..6e45e0521 100644
--- a/plugins/debian/debian.plugin.zsh
+++ b/plugins/debian/debian.plugin.zsh
@@ -21,8 +21,8 @@ fi
# Aliases ###################################################################
# These are for more obscure uses of apt-get and aptitude that aren't covered
# below.
-alias ag='apt-get'
-alias ap='aptitude'
+alias age='apt-get'
+alias api='aptitude'
# Some self-explanatory aliases
alias acs="apt-cache search"
diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh
index 38d419813..625201a16 100755
--- a/plugins/emacs/emacsclient.sh
+++ b/plugins/emacs/emacsclient.sh
@@ -3,7 +3,7 @@
# get list of available X windows.
x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null`
-if [ -z "$x" ] ;then
+if [ -z "$x" ] || [ "$x" = "nil" ] ;then
# Create one if there is no X window yet.
emacsclient --alternate-editor "" --create-frame "$@"
else
diff --git a/plugins/jsontools/README.md b/plugins/jsontools/README.md
new file mode 100644
index 000000000..4faf58b98
--- /dev/null
+++ b/plugins/jsontools/README.md
@@ -0,0 +1,42 @@
+# jsontools
+
+Handy command line tools for dealing with json data.
+
+## Tools
+
+- **pp_json** - pretty prints json
+- **is_json** - returns true if valid json; false otherwise
+- **urlencode_json** - returns a url encoded string for the given json
+- **urldecode_json** - returns decoded json for the given url encoded string
+
+## Usage
+Usage is simple...just take your json data and pipe it into the appropriate jsontool.
+```sh
+<json data> | <jsontools tool>
+```
+## Examples
+
+##### pp_json
+
+```sh
+# curl json data and pretty print the results
+curl https://coderwall.com/bobwilliams.json | pp_json
+```
+
+##### is_json
+```sh
+# pretty print the contents of an existing json file
+less data.json | is_json
+```
+
+##### urlencode_json
+```sh
+# json data directly from the command line
+echo '{"b":2, "a":1}' | urlencode_json
+```
+
+##### urldecode_json
+```sh
+# url encoded string to decode
+echo '%7B%22b%22:2,%20%22a%22:1%7D%0A' | urldecode_json
+``` \ No newline at end of file
diff --git a/plugins/jsontools/jsontools.plugin.zsh b/plugins/jsontools/jsontools.plugin.zsh
index 7b6f8c585..20d5eb1c9 100644
--- a/plugins/jsontools/jsontools.plugin.zsh
+++ b/plugins/jsontools/jsontools.plugin.zsh
@@ -2,15 +2,38 @@
# Adds command line aliases useful for dealing with JSON
if [[ $(whence $JSONTOOLS_METHOD) = "" ]]; then
- JSONTOOLS_METHOD=""
+ JSONTOOLS_METHOD=""
fi
if [[ $(whence node) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xnode" ) ]]; then
- alias pp_json='node -e "console.log(JSON.stringify(process.argv[1]), null, 4)"'
+ alias pp_json='xargs -0 node -e "console.log(JSON.stringify(JSON.parse(process.argv[1]), null, 4));"'
+ alias is_json='xargs -0 node -e "try {json = JSON.parse(process.argv[1]);} catch (e) { console.log(false); json = null; } if(json) { console.log(true); }"'
+ alias urlencode_json='xargs -0 node -e "console.log(encodeURIComponent(process.argv[1]))"'
+ alias urldecode_json='xargs -0 node -e "console.log(decodeURIComponent(process.argv[1]))"'
elif [[ $(whence python) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xpython" ) ]]; then
alias pp_json='python -mjson.tool'
+ alias is_json='python -c "
+import json, sys;
+try:
+ json.loads(sys.stdin.read())
+except ValueError, e:
+ print False
+else:
+ print True
+sys.exit(0)"'
+ alias urlencode_json='python -c "
+import urllib, json, sys;
+print urllib.quote_plus(sys.stdin.read())
+sys.exit(0)"'
+ alias urldecode_json='python -c "
+import urllib, json, sys;
+print urllib.unquote_plus(sys.stdin.read())
+sys.exit(0)"'
elif [[ $(whence ruby) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xruby" ) ]]; then
alias pp_json='ruby -e "require \"json\"; require \"yaml\"; puts JSON.parse(STDIN.read).to_yaml"'
+ alias is_json='ruby -e "require \"json\"; begin; JSON.parse(STDIN.read); puts true; rescue Exception => e; puts false; end"'
+ alias urlencode_json='ruby -e "require \"uri\"; puts URI.escape(STDIN.read)"'
+ alias urldecode_json='ruby -e "require \"uri\"; puts URI.unescape(STDIN.read)"'
fi
unset JSONTOOLS_METHOD \ No newline at end of file
diff --git a/plugins/pow/pow.plugin.zsh b/plugins/pow/pow.plugin.zsh
index 7f86c0c76..d85c88777 100644
--- a/plugins/pow/pow.plugin.zsh
+++ b/plugins/pow/pow.plugin.zsh
@@ -21,8 +21,8 @@
rack_root(){
setopt chaselinks
- local orgdir=$(pwd)
- local basedir=$(pwd)
+ local orgdir="$(pwd)"
+ local basedir="$(pwd)"
while [[ $basedir != '/' ]]; do
test -e "$basedir/config.ru" && break
@@ -30,7 +30,7 @@ rack_root(){
basedir="$(pwd)"
done
- builtin cd $orgdir 2>/dev/null
+ builtin cd "$orgdir" 2>/dev/null
[[ ${basedir} == "/" ]] && return 1
echo $basedir
}
@@ -56,19 +56,19 @@ kapow(){
compctl -W ~/.pow -/ kapow
powit(){
- local basedir=$(pwd)
+ local basedir="$(pwd)"
local vhost=$1
[ ! -n "$vhost" ] && vhost=$(rack_root_detect)
if [ ! -h ~/.pow/$vhost ]
then
echo "pow: Symlinking your app with pow. ${vhost}"
- [ ! -d ~/.pow/${vhost} ] && ln -s $basedir ~/.pow/$vhost
+ [ ! -d ~/.pow/${vhost} ] && ln -s "$basedir" ~/.pow/$vhost
return 1
fi
}
powed(){
- local basedir=$(rack_root)
+ local basedir="$(rack_root)"
find ~/.pow/ -type l -lname "*$basedir*" -exec basename {}'.dev' \;
}
@@ -82,4 +82,4 @@ repow(){
}
# View the standard out (puts) from any pow app
-alias kaput="tail -f ~/Library/Logs/Pow/apps/*" \ No newline at end of file
+alias kaput="tail -f ~/Library/Logs/Pow/apps/*"
diff --git a/plugins/rake-fast/README.md b/plugins/rake-fast/README.md
new file mode 100644
index 000000000..f56142f69
--- /dev/null
+++ b/plugins/rake-fast/README.md
@@ -0,0 +1,23 @@
+# rake-fast
+
+Fast rake autocompletion plugin.
+
+This script caches the output for later usage and significantly speeds it up. It generates a .rake_tasks cache file in parallel to the Rakefile. It also checks the file modification dates to see if it needs to regenerate the cache file.
+
+This is entirely based on [this pull request by Ullrich Schäfer](https://github.com/robb/.dotfiles/pull/10/), which is inspired by [this Ruby on Rails trick from 2006](http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh/).
+
+Think about that. 2006.
+
+## Installation
+
+Just add the plugin to your `.zshrc`:
+
+```bash
+plugins=(foo bar rake-fast)
+```
+
+You might consider adding `.rake_tasks` to your [global .gitignore](https://help.github.com/articles/ignoring-files#global-gitignore)
+
+## Usage
+
+`rake`, then press tab
diff --git a/plugins/rake-fast/rake-fast.plugin.zsh b/plugins/rake-fast/rake-fast.plugin.zsh
index 320855233..cb84f69a1 100644
--- a/plugins/rake-fast/rake-fast.plugin.zsh
+++ b/plugins/rake-fast/rake-fast.plugin.zsh
@@ -1,20 +1,3 @@
-# rake-fast
-# Fast rake autocompletion plugin for oh-my-zsh
-
-# This script caches the output for later usage and significantly speeds it up.
-# It generates a .rake_tasks file in parallel to the Rakefile.
-
-# You'll want to add `.rake_tasks` to your global .git_ignore file:
-# https://help.github.com/articles/ignoring-files#global-gitignore
-
-# You can force .rake_tasks to refresh with:
-# $ rake_refresh
-
-# This is entirely based on Ullrich Schäfer's work
-# (https://github.com/robb/.dotfiles/pull/10/),
-# which is inspired by this Ruby on Rails trick from 2006:
-# http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh/
-
_rake_refresh () {
if [ -f .rake_tasks ]; then
rm .rake_tasks
@@ -27,8 +10,13 @@ _rake_refresh () {
_rake_does_task_list_need_generating () {
if [ ! -f .rake_tasks ]; then return 0;
else
- accurate=$(stat -f%m .rake_tasks)
- changed=$(stat -f%m Rakefile)
+ if [[ $(uname -s) == 'Darwin' ]]; then
+ accurate=$(stat -f%m .rake_tasks)
+ changed=$(stat -f%m Rakefile)
+ else
+ accurate=$(stat -c%Y .rake_tasks)
+ changed=$(stat -c%Y Rakefile)
+ fi
return $(expr $accurate '>=' $changed)
fi
}
diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template
index 7b7f1df85..5b2a6cf49 100644
--- a/templates/zshrc.zsh-template
+++ b/templates/zshrc.zsh-template
@@ -11,34 +11,34 @@ ZSH_THEME="robbyrussell"
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
-# Set this to use case-sensitive completion
+# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
-# Uncomment this to disable bi-weekly auto-update checks
+# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
-# Uncomment to change how often to auto-update? (in days)
+# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
-# Uncomment following line if you want to disable colors in ls
+# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
-# Uncomment following line if you want to disable autosetting terminal title.
+# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
-# Uncomment following line if you want to disable command autocorrection
+# Uncomment the following line to disable command auto-correction.
# DISABLE_CORRECTION="true"
-# Uncomment following line if you want red dots to be displayed while waiting for completion
+# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"
-# Uncomment following line if you want to disable marking untracked files under
-# VCS as dirty. This makes repository status check for large repositories much,
-# much faster.
+# Uncomment the following line if you want to disable marking untracked files
+# under VCS as dirty. This makes repository status check for large repositories
+# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
-# Uncomment following line if you want to the command execution time stamp shown
-# in the history command output.
+# Uncomment the following line if you want to change the command execution time
+# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"
@@ -60,7 +60,7 @@ export PATH=$HOME/bin:/usr/local/bin:$PATH
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
-# # Preferred editor for local and remote sessions
+# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else