tmux-plugins / tmux-urlview

Quickly open any url on your terminal window!
MIT License
262 stars 32 forks source link

Delete temp file after script finishes #18

Open Boruch-Baum opened 7 years ago

Boruch-Baum commented 7 years ago

For me, this isn't worth forking and making a pull request. Here are my minor changes to to your nice script, basically to just clean up after itself. Also, it removes some repetitive bash-shms, and uses the canonical method for creating a temp file.

readonly key="$(get_tmux_option "@urlview-key" "u")"
readonly cmd="$(find_executable)"
readonly temp_file="$(mktemp --tmpdir tmux-urlview.XXX)"

if [ -z "$cmd" ]; then
  tmux display-message "Failed to load tmux-urlview: neither urlview nor extract_url were found on the PATH"
else
  tmux bind-key "$key" capture-pane -J \\\; \
    save-buffer "$temp_file" \\\; \
    delete-buffer \\\; \
    split-window -l 10 "$cmd '$temp_file'; rm '$temp_file' "
fi