aboutsummaryrefslogtreecommitdiff
path: root/local
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2017-10-20 18:10:08 +0200
committerKarel Kočí <cynerd@email.cz>2017-10-20 18:10:08 +0200
commite908c03fe775787c048ead719220e64b5af8bfe6 (patch)
tree59acfa1f8b95db60de9ebab0ba9d256735c5b4c7 /local
parent1254632045b0879f7149727324859d0951faa427 (diff)
downloadmyconfigs-e908c03fe775787c048ead719220e64b5af8bfe6.tar.gz
myconfigs-e908c03fe775787c048ead719220e64b5af8bfe6.tar.bz2
myconfigs-e908c03fe775787c048ead719220e64b5af8bfe6.zip
Update surf configuration
Diffstat (limited to 'local')
-rwxr-xr-xlocal/bin/surf-menu39
1 files changed, 29 insertions, 10 deletions
diff --git a/local/bin/surf-menu b/local/bin/surf-menu
index bd13e6b..f4925f8 100755
--- a/local/bin/surf-menu
+++ b/local/bin/surf-menu
@@ -3,17 +3,27 @@ set -e
BOOKMARDS=~/notes/bookmarks.md
-# Note: Bookmarks starts with '* '
-sed -n 's/\* //p' "$BOOKMARDS" | dmenu -p 'surf' | while read L; do
- if echo "$L" | grep -qE '^\?'; then # We do search on duckduckgo
+run() {
+ echo "Run $1"
+ echo "$1" | grep -qE '^~?/' || true
+ echo $?
+ if echo "$1" | grep -qE '^\?'; then # We do search on duckduckgo
- surf "https://duckduckgo.com/?q=${L#?}&t=surf&kk=-1&ia=web"
+ surf "https://duckduckgo.com/?q=${L#?}&t=surf&kk=-1&ia=web" &
+
+ elif echo "$1" | grep -qE '^~?/'; then # This is local path
+
+ surf "${1/#\~/$HOME}" &
+
+ elif echo "$1" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'; then # This ipv4 address
+
+ surf "$1" &
else # We follow address
- LPROTOCOL="$(echo "$L" | sed -n 's#^\([^:]*\)://.*#\1#p')"
- LHOST="$(echo "$L" | sed -n 's#^[^:]*://##;s#^\([^/]\+\)/\?.*#\1#p')"
- LPATH="$(echo "$L" | sed 's#^[^:]*://##;s#^[^/]\+/\?##')"
+ LPROTOCOL="$(echo "$1" | sed -n 's#^\([^:]*\)://.*#\1#p')"
+ LHOST="$(echo "$1" | sed -n 's#^[^:]*://##;s#^\([^/]\+\)/\?.*#\1#p')"
+ LPATH="$(echo "$1" | sed 's#^[^:]*://##;s#^[^/]\+/\?##')"
# Try to lookup if it's an real address
# Note: This is hack because of youtube, nslookup return No answer but
@@ -36,8 +46,17 @@ sed -n 's/\* //p' "$BOOKMARDS" | dmenu -p 'surf' | while read L; do
fi
fi
- surf "$LPROTOCOL://$LHOST/$LPATH" & # run backgrounded
+ surf "$LPROTOCOL://$LHOST/$LPATH" &
fi
-
-done
+}
+
+if [ -n "$1" ]; then
+ run "$1"
+ exit
+else
+ # Note: Bookmarks starts with '* '
+ sed -n 's/\* //p' "$BOOKMARDS" | dmenu -p 'surf' | while read L; do
+ run "$L"
+ done
+fi