diff options
author | Urbain Vaes <urbain@vaes.uk> | 2016-03-04 13:05:16 +0000 |
---|---|---|
committer | Urbain Vaes <urbain@vaes.uk> | 2016-03-04 13:05:16 +0000 |
commit | b39a06039d752855abaa2141404eb10f2d261a41 (patch) | |
tree | 8acc324a9c51b78e8b0e1adfd1d22c2d89a42bc3 /.qutebrowser | |
parent | 4393b8b173c0910f37734dc8fbc7acade0547542 (diff) |
Improve url-from-surfraw
Diffstat (limited to '.qutebrowser')
-rw-r--r-- | .qutebrowser/keys.conf | 3 | ||||
-rwxr-xr-x | .qutebrowser/userscripts/url-from-surfraw | 22 |
2 files changed, 14 insertions, 11 deletions
diff --git a/.qutebrowser/keys.conf b/.qutebrowser/keys.conf index 359789e..de9241c 100644 --- a/.qutebrowser/keys.conf +++ b/.qutebrowser/keys.conf @@ -53,6 +53,9 @@ clear-keychain ;; search set-cmd-text -s :spawn --userscript url-from-surfraw o +set-cmd-text -s :spawn --userscript url-from-surfraw -t + t + set-cmd-text :open {url} go diff --git a/.qutebrowser/userscripts/url-from-surfraw b/.qutebrowser/userscripts/url-from-surfraw index 3aaf30a..9bd6795 100755 --- a/.qutebrowser/userscripts/url-from-surfraw +++ b/.qutebrowser/userscripts/url-from-surfraw @@ -2,19 +2,19 @@ DEFAULT_SEARCH=startpage -string="$1 $2" +if [[ $1 =~ ^-.$ ]]; then + option="$1" + shift 1 +fi -set -- $string is_elvi=$(surfraw -elvi | grep -c "^$1\s") -nbr_words=$(echo "$string" | wc -w) -if [ "$nbr_words" -eq 1 ] && [ "$is_elvi" -eq 0 ] && ([[ "$string" == *.* ]] || [[ "$string" == *:* ]]) -then +nbr_words=$(echo $1 | wc -w) + +if [[ $is_elvi -eq 0 && $nbr_words -eq 1 && ($1 == *.* || $1 == *:*) ]]; then url="$1" -elif [ $is_elvi -eq 1 ] -then - url="$(surfraw -print $string)" -else - url="$(surfraw -print $DEFAULT_SEARCH $string)" +else + [[ $is_elvi -eq 0 ]] && sr="$DEFAULT_SEARCH $*" || sr=$* + url=$(surfraw -print $sr) fi -echo "open $url" >> "$QUTE_FIFO" +echo "open $option $url" >> $QUTE_FIFO |