From 8510ac002f1dec92f6e9e62809f3dc5493d4b842 Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Mon, 17 Sep 2012 19:05:42 -0700 Subject: [PATCH 1/6] Bundle exec puma also http://puma.io --- plugins/bundler/bundler.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh index 39b76ecdf..2305c4979 100644 --- a/plugins/bundler/bundler.plugin.zsh +++ b/plugins/bundler/bundler.plugin.zsh @@ -6,7 +6,7 @@ alias bu="bundle update" # The following is based on https://github.com/gma/bundler-exec -bundled_commands=(annotate cap capify cucumber foreman guard middleman nanoc rackup rainbows rake rspec ruby shotgun spec spork thin thor unicorn unicorn_rails) +bundled_commands=(annotate cap capify cucumber foreman guard middleman nanoc rackup rainbows rake rspec ruby shotgun spec spork thin thor unicorn unicorn_rails puma) ## Functions From b609aa0e6c981f2039d777687cb01a84587f6edc Mon Sep 17 00:00:00 2001 From: Jim Hester Date: Thu, 20 Sep 2012 08:03:09 -0400 Subject: [PATCH 2/6] Fix to restore bindings after switching to vi-mode the vi-mode plugin destroys any bindings made before it is sourced due to the 'bindkey -v' call to switch to using vi-mode. This patch saves the bindings before invoking 'bindkey -v' then rebinds them afterwards, this fixes a number of outstanding issues due to people using vi-mode and having things in oh-my-zsh break due to the bindings being destroyed --- plugins/vi-mode/vi-mode.plugin.zsh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index c47ab7211..d29eb1dda 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -5,7 +5,12 @@ function zle-line-init zle-keymap-select { zle -N zle-line-init zle -N zle-keymap-select +#changing mode clobbers the keybinds, so store the keybinds before and execute +#them after +binds=`bindkey -L` bindkey -v +for bind in ${(@f)binds}; do eval $bind; done +unset binds # if mode indicator wasn't setup by theme, define default if [[ "$MODE_INDICATOR" == "" ]]; then From baa187e4b903f39422a84b580e6e617ec3738e09 Mon Sep 17 00:00:00 2001 From: Jim Hester Date: Thu, 20 Sep 2012 08:23:58 -0400 Subject: [PATCH 3/6] Per directory history plugin This is a implementation of per directory history for zsh, some implementations of which exist in bash[1,2]. It also implements a per-directory-history-toggle-history function to change from using the directory history to using the global history. In both cases the history is always saved to both the global history and the directory history, so the toggle state will not effect the saved histories. Being able to switch between global and directory histories on the fly is a novel feature as far as I am aware. [1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html [2]: http://dieter.plaetinck.be/per_directory_bash --- .../per-directory-history.plugin.zsh | 149 ++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 plugins/per-directory-history/per-directory-history.plugin.zsh diff --git a/plugins/per-directory-history/per-directory-history.plugin.zsh b/plugins/per-directory-history/per-directory-history.plugin.zsh new file mode 100644 index 000000000..ce36db6af --- /dev/null +++ b/plugins/per-directory-history/per-directory-history.plugin.zsh @@ -0,0 +1,149 @@ +#!/usr/bin/env zsh +# +# This is a implementation of per directory history for zsh, some +# implementations of which exist in bash[1,2]. It also implements +# a per-directory-history-toggle-history function to change from using the +# directory history to using the global history. In both cases the history is +# always saved to both the global history and the directory history, so the +# toggle state will not effect the saved histories. Being able to switch +# between global and directory histories on the fly is a novel feature as far +# as I am aware. +# +#------------------------------------------------------------------------------- +# Configuration +#------------------------------------------------------------------------------- +# +# HISTORY_BASE a global variable that defines the base directory in which the +# directory histories are stored +# +#------------------------------------------------------------------------------- +# History +#------------------------------------------------------------------------------- +# +# The idea/inspiration for a per directory history is from Stewart MacArthur[1] +# and Dieter[2], the implementation idea is from Bart Schaefer on the the zsh +# mailing list[3]. The implementation is by Jim Hester in September 2012. +# +# [1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html +# [2]: http://dieter.plaetinck.be/per_directory_bash +# [3]: http://www.zsh.org/mla/users/1997/msg00226.html +# +################################################################################ +# +# Copyright (c) 2012 Jim Hester +# +# This software is provided 'as-is', without any express or implied warranty. +# In no event will the authors be held liable for any damages arising from the +# use of this software. +# +# Permission is granted to anyone to use this software for any purpose, +# including commercial applications, and to alter it and redistribute it +# freely, subject to the following restrictions: +# +# 1. The origin of this software must not be misrepresented; you must not claim +# that you wrote the original software. If you use this software in a product, +# an acknowledgment in the product documentation would be appreciated but is +# not required. +# +# 2. Altered source versions must be plainly marked as such, and must not be +# misrepresented as being the original software. +# +# 3. This notice may not be removed or altered from any source distribution.. +# +################################################################################ + +#------------------------------------------------------------------------------- +# configuration, the base under which the directory histories are stored +#------------------------------------------------------------------------------- + +[[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history" + +#------------------------------------------------------------------------------- +# toggle global/directory history used for searching - ctrl-G by default +#------------------------------------------------------------------------------- + +function per-directory-history-toggle-history() { + if [[ $_per_directory_history_is_global == true ]]; then + _per-directory-history-set-directory-history + echo "using local history\n" + else + _per-directory-history-set-global-history + echo "using global history\n" + fi + zle reset-prompt +} + +autoload per-directory-history-toggle-history +zle -N per-directory-history-toggle-history +bindkey '^G' per-directory-history-toggle-history + +#------------------------------------------------------------------------------- +# implementation details +#------------------------------------------------------------------------------- + +_per_directory_history_global=$HISTFILE +_per_directory_history_directory="$HISTORY_BASE${PWD:A}/history" + +function _per-directory-history-change-directory() { + _per_directory_history_directory="$HISTORY_BASE${PWD:A}/history" + mkdir -p ${_per_directory_history_directory:h} + if [[ $_per_directory_history_is_global == false ]]; then + #save to the global history + fc -AI $_per_directory_history_global + #save history to previous file + local prev="$HISTORY_BASE${OLDPWD:A}/history" + mkdir -p ${prev:h} + fc -AI $prev + + #discard previous directory's history + local original_histsize=$HISTSIZE + HISTSIZE=0 + HISTSIZE=$original_histsize + + #read history in new file + if [[ -e $_per_directory_history_directory ]]; then + fc -R $_per_directory_history_directory + fi + fi +} + +function _per-directory-history-addhistory() { + print -sr -- ${1%%$'\n'} + fc -p $_per_directory_history_directory +} + + +function _per-directory-history-set-directory-history() { + if [[ $_per_directory_history_is_global == true ]]; then + fc -AI $_per_directory_history_global + local original_histsize=$HISTSIZE + HISTSIZE=0 + HISTSIZE=$original_histsize + if [[ -e "$_per_directory_history_directory" ]]; then + fc -R "$_per_directory_history_directory" + fi + fi + _per_directory_history_is_global=false +} +function _per-directory-history-set-global-history() { + if [[ $_per_directory_history_is_global == false ]]; then + fc -AI $_per_directory_history_directory + local original_histsize=$HISTSIZE + HISTSIZE=0 + HISTSIZE=$original_histsize + if [[ -e "$_per_directory_history_global" ]]; then + fc -R "$_per_directory_history_global" + fi + fi + _per_directory_history_is_global=true +} + + +#add functions to the exec list for chpwd and zshaddhistory +chpwd_functions=(${chpwd_functions[@]} "_per-directory-history-change-directory") +zshaddhistory_functions=(${zshaddhistory_functions[@]} "_per-directory-history-addhistory") + +#start in directory mode +mkdir -p ${_per_directory_history_directory:h} +_per_directory_history_is_global=true +_per-directory-history-set-directory-history From aeadd7371b244468aadf81a48e6009a4aa612f23 Mon Sep 17 00:00:00 2001 From: Jim Hester Date: Thu, 20 Sep 2012 08:29:05 -0400 Subject: [PATCH 4/6] Colemak plugin a plugin for useing the colemak[1] keyboard layout and vi-mode in zsh, rotates some keys around in vi command mode so that the physical hjkl keys are still used for movement, all the rotated keys are either in colemak's location or qwerty's location, so it is easy to pick up [1] www.colemak.com --- plugins/colemak/colemak-less | 6 ++++++ plugins/colemak/colemak.plugin.zsh | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 plugins/colemak/colemak-less create mode 100644 plugins/colemak/colemak.plugin.zsh diff --git a/plugins/colemak/colemak-less b/plugins/colemak/colemak-less new file mode 100644 index 000000000..e4ca4facd --- /dev/null +++ b/plugins/colemak/colemak-less @@ -0,0 +1,6 @@ +n forw-line +e back-line +k repeat-search +\ek repeat-search-all +K reverse-search +\eK reverse-search-all diff --git a/plugins/colemak/colemak.plugin.zsh b/plugins/colemak/colemak.plugin.zsh new file mode 100644 index 000000000..34d42c280 --- /dev/null +++ b/plugins/colemak/colemak.plugin.zsh @@ -0,0 +1,22 @@ +# ctrl-j newline +bindkey '^n' accept-line +bindkey -a '^n' accept-line + +# another rotation to match qwerty +bindkey -a 'n' down-line-or-history +bindkey -a 'e' up-line-or-history +bindkey -a 'i' vi-forward-char + +# make qwerty +bindkey -a 'k' vi-repeat-search +bindkey -a 'K' vi-rev-repeat-search +bindkey -a 'u' vi-insert +bindkey -a 'U' vi-insert-bol +bindkey -a 'l' vi-undo-change +bindkey -a 'N' vi-join + +# spare +bindkey -a 'j' vi-forward-word-end +bindkey -a 'J' vi-forward-blank-word-end + +lesskey $ZSH_CUSTOM/plugins/colemak/colemak-less From 7284e6b397712dfff16a740ea12d1015b26f203d Mon Sep 17 00:00:00 2001 From: Aviad Reich Date: Fri, 21 Sep 2012 08:08:53 +0300 Subject: [PATCH 5/6] added autojump plugin support for mac os x + port --- plugins/autojump/autojump.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index 6f0edb062..d367863b8 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -3,6 +3,8 @@ if [ $commands[autojump] ]; then # check if autojump is installed . /usr/share/autojump/autojump.zsh elif [ -f /etc/profile.d/autojump.zsh ]; then # manual installation . /etc/profile.d/autojump.zsh + elif [ -f /opt/local/etc/profile.d/autojump.zsh ]; then # mac os x with ports + . /opt/local/etc/profile.d/autojump.zsh elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump ]; then # mac os x with brew . `brew --prefix`/etc/autojump fi From cc831508d7c2e839e1c4effe31ac2d92f2741f94 Mon Sep 17 00:00:00 2001 From: Jim Hester Date: Fri, 21 Sep 2012 10:19:39 -0400 Subject: [PATCH 6/6] Use HISTFILE evironment variable directly rather than copying it Use the HISTFILE environment variable in place of copying it to _per_directory_history_global so that users can change the environment variable after sourcing per-directory-history and have the global variable set correctly --- .../per-directory-history.plugin.zsh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/per-directory-history/per-directory-history.plugin.zsh b/plugins/per-directory-history/per-directory-history.plugin.zsh index ce36db6af..22383b8b9 100644 --- a/plugins/per-directory-history/per-directory-history.plugin.zsh +++ b/plugins/per-directory-history/per-directory-history.plugin.zsh @@ -81,7 +81,6 @@ bindkey '^G' per-directory-history-toggle-history # implementation details #------------------------------------------------------------------------------- -_per_directory_history_global=$HISTFILE _per_directory_history_directory="$HISTORY_BASE${PWD:A}/history" function _per-directory-history-change-directory() { @@ -89,7 +88,7 @@ function _per-directory-history-change-directory() { mkdir -p ${_per_directory_history_directory:h} if [[ $_per_directory_history_is_global == false ]]; then #save to the global history - fc -AI $_per_directory_history_global + fc -AI $HISTFILE #save history to previous file local prev="$HISTORY_BASE${OLDPWD:A}/history" mkdir -p ${prev:h} @@ -115,7 +114,7 @@ function _per-directory-history-addhistory() { function _per-directory-history-set-directory-history() { if [[ $_per_directory_history_is_global == true ]]; then - fc -AI $_per_directory_history_global + fc -AI $HISTFILE local original_histsize=$HISTSIZE HISTSIZE=0 HISTSIZE=$original_histsize @@ -131,8 +130,8 @@ function _per-directory-history-set-global-history() { local original_histsize=$HISTSIZE HISTSIZE=0 HISTSIZE=$original_histsize - if [[ -e "$_per_directory_history_global" ]]; then - fc -R "$_per_directory_history_global" + if [[ -e "$HISTFILE" ]]; then + fc -R "$HISTFILE" fi fi _per_directory_history_is_global=true