Skip to content

Commit

Permalink
fix: dedupe should be done inplace
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaitanyabsprip committed Jul 12, 2024
1 parent 3fa9e0b commit abc448e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions harpoon
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ _getBookmark() {
tmux display -p "$base_info$([ "$extended" = true ] && echo "$pane_info")"
}

_dedupe() { command cat -n "$cachefile" | sort -uk2 | sort -n | cut -f2-; }
_dedupe() {
tmpfile="$(mktemp)"
command cat -n "$cachefile" | sort -uk2 | sort -n | cut -f2- >"$tmpfile"
mv "$tmpfile" "$cachefile"
rm "$tmpfile"
}

replace() {
bookmark=$(_getBookmark "$1")
Expand All @@ -97,7 +102,6 @@ replace() {

add() {
bookmark=$(_getBookmark "$1")

echo "$bookmark" >>"$cachefile"
_dedupe
exec tmux display 'Tracking session #{session_name}'
Expand Down

0 comments on commit abc448e

Please sign in to comment.