1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-25 15:20:08 +00:00

Update to latest per-directory-history

This commit is contained in:
Jim Hester 2013-03-13 13:07:32 -04:00
parent 0744acd663
commit ac6f1a045c

View file

@ -1,27 +1,27 @@
#!/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 @@
# #
# 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() {
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() {
} }
function _per-directory-history-addhistory() { function _per-directory-history-addhistory() {
print -sr -- ${1%%$'\n'} print -Sr -- ${1%%$'\n'}
fc -a -p $_per_directory_history_directory fc -p $_per_directory_history_directory
} }