diff --git a/.sackrc b/.sackrc index e831912..8619c52 100644 --- a/.sackrc +++ b/.sackrc @@ -10,8 +10,8 @@ sack__shortcut_cmd=F sack__shortcut_path=~/bin -# File to store the shortcuts so they can be used across terminal / shell sessions -sack__shortcut_file=~/.sack_shortcuts +# Directory to store the shortcuts so they can be used across terminal / shell sessions +sack__shortcut_dir=~/.sack_shortcuts # Toggle the instructions after search results; 0 for off sack__show_instructions=0 diff --git a/sack b/sack index e66dfd9..7778cce 100755 --- a/sack +++ b/sack @@ -153,7 +153,7 @@ create_shortcut_cmd_vim() { sack__shortcut_cmd_path=$sack__shortcut_path/$sack__shortcut_cmd cat > $sack__shortcut_cmd_path < $sack__shortcut_cmd_path - echo "sack__rsub_shortcut=\$(sed -n \"\$1p\" < $sack__shortcut_file)" >> $sack__shortcut_cmd_path + echo "sack__rsub_shortcut=\$(sed -n \"\$1p\" < $sack__shortcut_dir/$PPID)" >> $sack__shortcut_cmd_path echo "fp=\`echo \$sack__rsub_shortcut | awk '{ print \$2 }'\`" >> $sack__shortcut_cmd_path echo "ln=\`echo \$sack__rsub_shortcut | awk '{ print \$1 }'\`" >> $sack__shortcut_cmd_path echo "$sack__default_editor -l \$ln \$fp" >> $sack__shortcut_cmd_path @@ -549,6 +549,9 @@ else sack__cwd=$(eval "echo $sack__cwd") fi +# Ensure the shortcut directory exists +mkdir -p "$sack__shortcut_dir" + # Announce start of sack: echo "" echo "============> running $sack__default_tool! <============" @@ -561,7 +564,7 @@ echo "===> Searching parameters: $@" echo "" # The actual wrapper around ack -$sack__default_tool $sack__color_param $sack__flags "$@" "$sack__cwd" | tee >$sack__dev_null >(display_shortcuts) >(process_shorcut_paths | remove_escaped_chars > $sack__shortcut_file) +$sack__default_tool $sack__color_param $sack__flags "$@" "$sack__cwd" | tee >$sack__dev_null >(display_shortcuts) >(process_shorcut_paths | remove_escaped_chars > $sack__shortcut_dir/$PPID) # Show usage instructions for first-time users; this can be turned off if [[ $sack__show_instructions -eq 0 ]]; then diff --git a/sag b/sag index cb3cee8..9cf00fb 100755 --- a/sag +++ b/sag @@ -30,4 +30,4 @@ # ============================================================== # ============================================================== -sack -ag "$@" +exec sack -ag "$@"