aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/url_search.sh53
-rw-r--r--stow/tmux/.tmux.conf2
2 files changed, 7 insertions, 48 deletions
diff --git a/scripts/url_search.sh b/scripts/url_search.sh
index 9276126..497b09c 100755
--- a/scripts/url_search.sh
+++ b/scripts/url_search.sh
@@ -5,52 +5,9 @@
# Date: 2019-04-25
#
# Description: Search buffer for url results
-#
-# Set options:
-# e: Stop script if command fails
-# u: Stop script if unset variable is referenced
-# x: Debug, print commands as they are executed
-# o pipefail: If any command in a pipeline fails it all fails
-#
-# IFS: Internal Field Separator
-set -euo pipefail
-IFS=$'\n\t'
-
-# Colors for printing
-G='\e[0;32m' # Green
-LG='\e[0;37m' # Light Gray
-C='\e[0;36m' # Cyan
-NC='\e[0m' # No Color
-
-# Immutable globals
-readonly ARGS=( "$@" )
-readonly NUM_ARGS="$#"
-readonly PROGNAME=$(basename "$0")
-readonly BUFFER='/tmp/tmuxcopy.log'
-POSITION=1
-
-cleanup() {
- rm -rf "$BUFFER"
-}
-
-create_buffer() {
- touch "$BUFFER"
- trap cleanup EXIT
-}
-
-capture_pane() {
- tmux capture-pane -S -9000000 -p > "$BUFFER"
-}
-
-find_urls() {
- perl -wnl -e '/https?\:\/\/[^\s]+[\/\w]/ and print $&' "$BUFFER"
-}
-# Main loop of program
-main() {
- create_buffer
- capture_pane
- URL=$(find_urls | tail -n "$POSITION")
- tmux copy-mode ; tmux send -X search-backward $URL
-}
-main
+PANE_HISTORY="$(tmux capture-pane -J -p)"
+URL=$(echo "$PANE_HISTORY" | perl -wnl -e '/https?\:\/\/[^\s]+[\/\w]/ and print $&' | fzf-tmux)
+if [[ -n "$URL" ]]; then
+ echo "$URL" | xp
+fi
diff --git a/stow/tmux/.tmux.conf b/stow/tmux/.tmux.conf
index a7efe92..de4dbf3 100644
--- a/stow/tmux/.tmux.conf
+++ b/stow/tmux/.tmux.conf
@@ -21,6 +21,8 @@ bind L resize-pane -R 3
# Rollodex commands
bind n run-shell "bash $HOME/.tmux/scripts/rolodex.sh next"
bind p run-shell "bash $HOME/.tmux/scripts/rolodex.sh prev"
+# Url Searching
+bind C-u run-shell "bash $HOME/.tmux/scripts/url_search.sh"
# Bind the last window/pane command
bind C-b last-pane
bind C-f last-window