3cc61701bd7fd0a3fa6cb3c70f2b927a1e51970a

Author
Marc Cornellà <marc.cornella@live.com>
Committer
GitHub <noreply@github.com>
Date

Message

Update per-directory-history plugin to latest version (#5493)

Latest version: February 17, 2016 - dd81201

Diff

 1diff --git a/plugins/per-directory-history/README.md b/plugins/per-directory-history/README.md
 2index d8ff93dc0f18dd0e9cbccbe23d91fde6ded9f254..196f74e6c8368c103cb2a62937aa126ffd440625 100644
 3--- a/plugins/per-directory-history/README.md
 4+++ b/plugins/per-directory-history/README.md
 5@@ -27,9 +27,8 @@ Usage
 6 2.  The default mode if per directory history, interact with your history as normal.
 7 
 8 3.  Press ^G (the Control and G keys simultaneously) to toggle between local
 9-    and global histories. 
10-
11-
12+    and global histories.  If you would prefer a different shortcut to toggle
13+    set the PER_DIRECTORY_HISTORY_TOGGLE environment variable.
14 
15 -------------------------------------------------------------------------------
16 Configuration
17diff --git a/plugins/per-directory-history/per-directory-history.zsh b/plugins/per-directory-history/per-directory-history.zsh
18index bdee341bdca98f4958a380457480b59e5ba4a1f0..1242dc4204c99390b19a24bb148909446ac2907c 100644
19--- a/plugins/per-directory-history/per-directory-history.zsh
20+++ b/plugins/per-directory-history/per-directory-history.zsh
21@@ -30,7 +30,7 @@
22 #
23 ################################################################################
24 #
25-# Copyright (c) 2012 Jim Hester
26+# Copyright (c) 2014 Jim Hester
27 #
28 # This software is provided 'as-is', without any express or implied warranty. 
29 # In no event will the authors be held liable for any damages arising from the
30@@ -57,6 +57,7 @@
31 #-------------------------------------------------------------------------------
32 
33 [[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history"
34+[[ -z $PER_DIRECTORY_HISTORY_TOGGLE ]] && PER_DIRECTORY_HISTORY_TOGGLE='^G'
35 
36 #-------------------------------------------------------------------------------
37 # toggle global/directory history used for searching - ctrl-G by default
38@@ -76,7 +77,7 @@ function per-directory-history-toggle-history() {
39 
40 autoload per-directory-history-toggle-history
41 zle -N per-directory-history-toggle-history
42-bindkey '^G' per-directory-history-toggle-history
43+bindkey $PER_DIRECTORY_HISTORY_TOGGLE per-directory-history-toggle-history
44 
45 #-------------------------------------------------------------------------------
46 # implementation details
47@@ -108,7 +109,7 @@ function _per-directory-history-change-directory() {
48 }
49 
50 function _per-directory-history-addhistory() {
51-  print -Sr -- ${1%%$'\n'}
52+  print -Sr -- "${1%%$'\n'}"
53   fc -p $_per_directory_history_directory
54 }
55 
56@@ -140,8 +141,9 @@ function _per-directory-history-set-global-history() {
57 
58 
59 #add functions to the exec list for chpwd and zshaddhistory
60-chpwd_functions=(${chpwd_functions[@]} "_per-directory-history-change-directory")
61-zshaddhistory_functions=(${zshaddhistory_functions[@]} "_per-directory-history-addhistory")
62+autoload -U add-zsh-hook
63+add-zsh-hook chpwd _per-directory-history-change-directory
64+add-zsh-hook zshaddhistory _per-directory-history-addhistory
65 
66 #start in directory mode
67 mkdir -p ${_per_directory_history_directory:h}