Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Oh My Zsh
Commits
ac6f1a04
Commit
ac6f1a04
authored
Mar 13, 2013
by
Jim Hester
Browse files
Update to latest per-directory-history
parent
0744acd6
Changes
1
Hide whitespace changes
Inline
Side-by-side
plugins/per-directory-history/per-directory-history.zsh
View file @
ac6f1a04
#!/usr/bin/env zsh
#!/usr/bin/env zsh
#
#
# This is a implementation of per directory history for zsh, some
# This is a implementation of per directory history for zsh, some
# implementations of which exist in bash[1,2]. It also implements
# implementations of which exist in bash[1,2]. It also implements
# a per-directory-history-toggle-history function to change from using the
# 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
# 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
# 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
# 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
# between global and directory histories on the fly is a novel feature as far
# as I am aware.
# as I am aware.
#
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Configuration
# Configuration
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
#
# HISTORY_BASE a global variable that defines the base directory in which the
# HISTORY_BASE a global variable that defines the base directory in which the
# directory histories are stored
# directory histories are stored
#
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# History
# History
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
#
# The idea/inspiration for a per directory history is from Stewart MacArthur[1]
# 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
# 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.
# 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
# [1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html
...
@@ -32,20 +32,20 @@
...
@@ -32,20 +32,20 @@
#
#
# Copyright (c) 2012 Jim Hester
# Copyright (c) 2012 Jim Hester
#
#
# This software is provided 'as-is', without any express or implied warranty.
# 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
# In no event will the authors be held liable for any damages arising from the
# use of this software.
# use of this software.
#
#
# Permission is granted to anyone to use this software for any purpose,
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
# freely, subject to the following restrictions:
#
#
# 1. The origin of this software must not be misrepresented; you must not claim
# 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,
# 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
# an acknowledgment in the product documentation would be appreciated but is
# not required.
# not required.
#
#
# 2. Altered source versions must be plainly marked as such, and must not be
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# misrepresented as being the original software.
#
#
# 3. This notice may not be removed or altered from any source distribution..
# 3. This notice may not be removed or altered from any source distribution..
...
@@ -99,7 +99,7 @@ function _per-directory-history-change-directory() {
...
@@ -99,7 +99,7 @@ function _per-directory-history-change-directory() {
local
original_histsize
=
$HISTSIZE
local
original_histsize
=
$HISTSIZE
HISTSIZE
=
0
HISTSIZE
=
0
HISTSIZE
=
$original_histsize
HISTSIZE
=
$original_histsize
#read history in new file
#read history in new file
if
[[
-e
$_per_directory_history_directory
]]
;
then
if
[[
-e
$_per_directory_history_directory
]]
;
then
fc
-R
$_per_directory_history_directory
fc
-R
$_per_directory_history_directory
...
@@ -108,8 +108,8 @@ function _per-directory-history-change-directory() {
...
@@ -108,8 +108,8 @@ function _per-directory-history-change-directory() {
}
}
function
_per-directory-history-addhistory
()
{
function
_per-directory-history-addhistory
()
{
print
-
s
r
--
${
1
%%
$'
\n
'
}
print
-
S
r
--
${
1
%%
$'
\n
'
}
fc
-a
-p
$_per_directory_history_directory
fc
-p
$_per_directory_history_directory
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment