Skip to content

Commit

Permalink
zsh: make sack file shell-local
Browse files Browse the repository at this point in the history
  • Loading branch information
majutsushi committed Feb 9, 2015
1 parent 4bf9b58 commit 20a239a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
5 changes: 1 addition & 4 deletions zsh/sack
Expand Up @@ -10,9 +10,6 @@
BIN=$1
shift

# File to store the shortcuts so they can be used across terminal / shell sessions
shortcut_file=$XDG_CACHE_HOME/grep_shortcuts

# Prefixes a shortcut tag to relevant output lines.
display_shortcuts() {
# Note that by default ack uses the --nogroup -H option by default when
Expand Down Expand Up @@ -61,4 +58,4 @@ remove_escaped_chars() {
fi
}

$BIN --color "$@" | tee >/dev/null >(display_shortcuts) >(process_shorcut_paths | remove_escaped_chars > $shortcut_file) | less
$BIN --color "$@" | tee >/dev/null >(display_shortcuts) >(process_shorcut_paths | remove_escaped_chars > "${SACK_SHORTCUT_FILE}") | less
3 changes: 3 additions & 0 deletions zsh/zsh/zshrc.d/15_variables
Expand Up @@ -64,6 +64,9 @@ export GITHUB_USER=majutsushi

export NETHACKOPTIONS=@$HOME/.etc/nethackrc

export SACK_SHORTCUT_FILE="$XDG_CACHE_HOME/sack_shortcuts/$$"
mkdir -p "$(dirname "$SACK_SHORTCUT_FILE")"

# update session environment variables if they got changed after re-attaching
# a tmux session
if [[ -n "$TMUX" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion zsh/zsh/zshrc.d/30_aliases
Expand Up @@ -100,7 +100,7 @@ else
alias a='~/.etc/zsh/sack ack'
fi
f() {
local shortcut="$(sed -n "$1p" < $XDG_CACHE_HOME/grep_shortcuts | awk '
local shortcut="$(sed -n "$1p" < "$SACK_SHORTCUT_FILE" | awk '
{
print $1
file = $2
Expand Down

0 comments on commit 20a239a

Please sign in to comment.