Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintain sessions based on parent PID #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .sackrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions sack
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ create_shortcut_cmd_vim() {
sack__shortcut_cmd_path=$sack__shortcut_path/$sack__shortcut_cmd
cat > $sack__shortcut_cmd_path <<SHORTCUT
#!/bin/bash
sack__vim_shortcut=\$(sed -n "\$1p" < $sack__shortcut_file)
sack__vim_shortcut=\$(sed -n "\$1p" < $sack__shortcut_dir/\$PPID)
sack__line=\`echo \$sack__vim_shortcut | cut -d" " -f1\`
sack__file=\`echo \$sack__vim_shortcut | sed 's/'\$sack__line' //'\`
if [ -z "\$EDITOR" ]; then
Expand All @@ -171,7 +171,7 @@ create_shortcut_cmd_rsub() {

sack__shortcut_cmd_path=$sack__shortcut_path/$sack__shortcut_cmd
echo "#!/bin/bash" > $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
Expand Down Expand Up @@ -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! <============"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sag
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
# ==============================================================
# ==============================================================

sack -ag "$@"
exec sack -ag "$@"