You are not logged in.

#1 2016-12-23 05:27:39

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Bash bookmarking script

EDIT: latest script on the last page currently post #36


Here is my universal bookmarks manager, can be used with any browser.
I use it with rofi, can be used with dmenu also. Read the comments in code file. This is updated version of my previous post, I have replaced most grep lines with bash functions.

#!/bin/bash

# required "surfraw"-for keyword based search,
# default script uses rofi, to use with dmenu uncomment the dmenu line and comment out the line with "rofi -dmenu"
# place your browser in BROWSER=? line
# only if not using w3m 
    ## you can use your bookmarks text file with 1 url/line, put it in second "BOOKMARKS=?" field replacing /tmp/bookmarks, comment out first BOOKMARKS=? line along with "grep -o" line
# w3m users do not need to change BOOKMARKS=?

## USAGE ##
# simply type url, matched url will be selected by dmenu/rofi
# keywords can be used like "yt trailers", to search trailers on youtube, or "wi holocaust" to search on wikipedia, archwiki, imdb, google, aur, etc. are supported
# when input is not url and doesn't match with bookmarks it will be searched in duckduckgo
# if some url are not identified as url ( like goo.gl ), use ">" as a keyword

BROWSER=lariza
# only for w3m bookmarks/ comment out if not using w3m
BOOKMARKS=~/.w3m/bookmark.html
HISTORY=~/.w3m/history

# convert .w3m/bookmarks to simple text with 1 url/line; comment out if not using w3m
grep -o 'http[^"]*' $BOOKMARKS > /tmp/bookmarks
# add w3m history to the list of bookmarks
#grep -o 'http[^"]*' $HISTORY >> /tmp/bookmarks

# add your plain text bookmarks here (do not edit or comment out if using w3m bookmarks)
BOOKMARKS=/tmp/bookmarks

# for use with rofi
cat "$BOOKMARKS" | rofi -dmenu -location 1 -l 10 -width 100 -p $BROWSER: > /tmp/x
# for use with dmenu
# cat "$BOOKMARKS" | dmenu -l 10 -p $BROWSER: > /tmp/x

#check=$(wc -l < /tmp/x)
#(( $check == 0)) && exit
[[ ! $( < /tmp/x) ]] && exit

awk '{ print $1 }' /tmp/x > /tmp/y
awk '{ print $2, $3, $4, $5, $6, $7, $8 }' /tmp/x > /tmp/z

case "$( < /tmp/y )" in
http*)  $BROWSER "$( < /tmp/x)"
 ;;
\>) $BROWSER "$( < /tmp/z)"
 ;;
*www.*) $BROWSER "$( < /tmp/x)"
 ;;
*.com*) $BROWSER "$( < /tmp/x)"
 ;;
*.in*) $BROWSER "$( < /tmp/x)"
 ;;
*.edu*) $BROWSER "$( < /tmp/x)"
 ;;
*.org*) $BROWSER "$( < /tmp/x)"
 ;;
aw) archwiki -browser=$BROWSER "$( < /tmp/z)"
 ;;
wi) wikipedia -browser=$BROWSER "$( < /tmp/z)"
 ;;
imdb) imdb -browser=$BROWSER "$( < /tmp/z)"
 ;;
aur) aur -browser=$BROWSER "$( < /tmp/z)"
 ;;
pkg) archpkg -browser=$BROWSER "$( < /tmp/z)"
 ;;
google) google -browser=$BROWSER "$( < /tmp/z)"
 ;;
yt) youtube -browser=$BROWSER "$( < /tmp/z)"
 ;;
ebay) ebay -browser=$BROWSER "$( < /tmp/z)"
 ;;
pubmed) pubmed -browser=$BROWSER "$( < /tmp/z)"
 ;;
*) duckduckgo -browser=$BROWSER "$( < /tmp/x)"

esac

Kindly provide your comments to further update the script.

EDIT: latest script on the last page currently post #36

Last edited by Docbroke (2017-12-01 05:18:05)

Offline

#2 2016-12-23 13:36:28

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,441
Website

Re: Bash bookmarking script

What is the second awk for?  It looks like you are trying to get any additional parameters passed, but you have hardcoded this to be 8.  Why not just let it be any number:

awk '{ $1=""; print $0; }' ...

You also can do it with one awk:

awk '{ print $1 > "/tmp/y"; $1=""; print $0 > "/tmp/z";}'

But even this doesn't serve a purpose as all you seem to be doing is tokenizing the line - don't even use a file, just pipe the output of dmenu/rofi:

dmenu ... | read  url opts
case $url in
   ...) $BROWSER $opts ;;

There is also a useless use of cat in the rofi/dmenu lines, just use <

So everything from the rofi/dmenu lines down could just be as:

rofi -dmenu -location 1 -l 10 -width 100 -p $BROWSER: < "$BOOKMARKS" | read url opts
# dmenu -l 10 -p $BROWSER: < "$BOOKMARKS" | read url opts

case $url in
	http*)   $BROWSER $url ;;
	\>)      $BROWSER $opts ;;
	*www.*)  $BROWSER $url ;;
	*.com*)  $BROWSER $url ;;
	*.in*)   $BROWSER $url ;;
	*.edu*)  $BROWSER $url ;;
	*.org*)  $BROWSER $url ;;
	aw)      archwiki    -browser=$BROWSER $opts ;;
	wi)      wikipedia   -browser=$BROWSER $opts ;;
	imdb)    imdb        -browser=$BROWSER $opts ;;
	aur)     aur         -browser=$BROWSER $opts ;;
	pkg)     archpkg     -browser=$BROWSER $opts ;;
	google)  google      -browser=$BROWSER $opts ;;
	yt)      youtube     -browser=$BROWSER $opts ;;
	ebay)    ebay        -browser=$BROWSER $opts ;;
	pubmed)  pubmed      -browser=$BROWSER $opts ;;
	*)       duckduckgo  -browser=$BROWSER $url ;;
esac

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2016-12-23 14:27:11

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Re: Bash bookmarking script

thansk Trilby, for suggestions, but when I tried, piping to read seems to fail as whatever url or keyword I input in rofi, it only opens duckduckgo.

Offline

#4 2016-12-23 14:32:12

Alad
Wiki Admin/IRC Op
From: Bagelstan
Registered: 2014-05-04
Posts: 2,407
Website

Re: Bash bookmarking script

shopt -s lastpipe

Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby

Offline

#5 2016-12-23 14:43:25

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Re: Bash bookmarking script

thanks Alad, shopt solved one issue, I need to add that to .bashrc
second issue now is $opt in the script is like $2, so if there are more search terms after keyword they are lost. Like if I want to search "arch linux website" it will give only "arch" to duckduckgo

Offline

#6 2016-12-23 15:39:28

Alad
Wiki Admin/IRC Op
From: Bagelstan
Registered: 2014-05-04
Posts: 2,407
Website

Re: Bash bookmarking script

Non-interactive shells (e.g. scripts) don't source .bashrc in Arch (probably a good thing), so you'd need to add the shopt to your script anyway. Or use process substitution.

second issue now is $opt in the script is like $2, so if there are more search terms after keyword they are lost. Like if I want to search "arch linux website" it will give only "arch" to duckduckgo

Fix the quoting. Right now "opts" takes the rest of the line but is split on whitespace in the case statement.

Last edited by Alad (2016-12-23 15:40:17)


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby

Offline

#7 2016-12-23 15:43:09

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,441
Website

Re: Bash bookmarking script

The case value is just url, right?  So quoting of $opts shouldn't matter.  $opts in the individual case conditions is expanded to all the words, so that should be right.  Although I'm not sure what the later case conditionals do.  They seem to call functions/binaries/alias with names like "archwiki".  If that function/binary/alias can take multiple args, all is fine.  If it expects everything after --browser to be in a single argument, then yest $opts would have to be quoted.

EDIT: I guess those are surfraw scripts.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2016-12-23 16:29:26

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Re: Bash bookmarking script

yes these are surfraw scripts, $opts needs to be quoted, as an example if search term is "wi bill clinton" , wi is $url and "bill clinton" is $opt.
The issue with duckduckgo is we need to give entire search to that (both $url and $opt) so line now looks like

*)       duckduckgo  -browser=$BROWSER $url $opts ;;

and this works.
    thanks

    EDIT: I was wrong about quoting $opt, it was not needed, the issue gets solved with changing duckduckgo line.
    In fact I am not using surfraw for duckduckgo search as it uses duckduckgo/lite version, so I am using my own script to search duckduckgo.
So final updated script is here

#!/bin/bash

### DEPENDS ON ###
    # "surfraw"-for keyword based search, you will need /usr/lib/surfraw in your path, so add below line to your .bashrc (uncommented)
    # PATH=/usr/lib/surfraw:${PATH}
### CONFIGURATION ###
    # place your browser in BROWSER=? line
    ## only if not using w3m 
	# you can use your bookmarks text file with 1 url/line, put it in second "BOOKMARKS=?" field replacing /tmp/bookmarks, comment out first "BOOKMARKS=?" line & grep -o line
    # w3m users do not need to change BOOKMARKS=?
    # default script uses rofi, to use dmenu uncomment the line starting with dmenu and comment out previous line starting with rofi
### USE ###
    # enter text in rofi/dmenu field, it will be matched against bookmarks, <enter> to open selected bookmark
    # to search specific sites use keyword as first argument ( like go for google, wi for wikipedia, aw for archwiki etc.) > read the script to find out all keywords
    # if no keyword or url is used, entire argument will be searched with duckduckgo
    # url is identified with http/www/org/com/edu/in etc., for other urls use ">" as keyword elsed it will go to duckduckgo
    # to use enterd text directly (not the matching bookmark) use <C-enter> (rofi only)
    # to edit selected bookmark use <C-space> (rofi only)

BROWSER=lariza
# only for w3m bookmarks/ comment out if not using w3m
BOOKMARKS=~/.w3m/bookmark.html
HISTORY=~/.w3m/history

# convert .w3m/bookmarks to simple text with 1 url/line; comment out if not using w3m
grep -o 'http[^"]*' $BOOKMARKS > /tmp/bookmarks
# add w3m history to the list of bookmarks
# grep -o 'http[^"]*' $HISTORY >> /tmp/bookmarks

shopt -s lastpipe
# add your plain text bookmarks here (do not edit or comment out if using w3m bookmarks)
BOOKMARKS=/tmp/bookmarks
rofi -dmenu -location 1 -l 10 -width 100 -p $BROWSER: < "$BOOKMARKS" | read -a url
# dmenu -l 10 -p $BROWSER: < "$BOOKMARKS" | read -a url

[[ ! $url ]] && exit

case "${url[0]}" in
    http*)   $BROWSER "${url[@]}" ;;
    \>)      $BROWSER "${url[@]:1}" ;;
    *www.*)  $BROWSER "${url[@]}" ;;
    *.com*)  $BROWSER "${url[@]}" ;;
    *.in*)   $BROWSER "${url[@]}" ;;
    *.edu*)  $BROWSER "${url[@]}" ;;
    *.org*)  $BROWSER "${url[@]}" ;;
    aw|awiki)   archwiki    -browser=$BROWSER "${url[@]:1}" ;;
    wi|wiki)    wikipedia   -browser=$BROWSER "${url[@]:1}" ;;
    imdb)	imdb        -browser=$BROWSER "${url[@]:1}" ;;
    aur)	aur         -browser=$BROWSER "${url[@]:1}" ;;
    pkg)	archpkg     -browser=$BROWSER "${url[@]:1}" ;;
    go|google)  google      -browser=$BROWSER "${url[@]:1}" ;;
    map)	google -m   -browser=$BROWSER "${url[@]:1}" ;;
    image)	google -i   -browser=$BROWSER "${url[@]:1}" ;;   
    video)	google -v   -browser=$BROWSER "${url[@]:1}" ;;   
    news)	google -n   -browser=$BROWSER "${url[@]:1}" ;;      
    yt|youtube)	youtube     -browser=$BROWSER "${url[@]:1}" ;;
    ebay)	ebay        -browser=$BROWSER "${url[@]:1}" ;;
    pubmed)	pubmed      -browser=$BROWSER "${url[@]:1}" ;;
    git|github)	github      -browser=$BROWSER "${url[@]:1}" ;;
#   def) notify-send -t 9999999 "$( sdcv --data-dir ~/dic/english/ "${url[@]:1}" )" ;;
    *)	 duckduckgo -j	    -browser=$BROWSER "${url[@]}" ;;
esac

I am still looking to improve the way url is identified ( here I am using http/www/.com/.in/.edu/.org as identifiers, but I guess this can be improved, as it misses urls like goo.gl)

here qddg is this script, to use it put this in path and replace lariza with your browser, or replace qddg in previous script with "duckduckgo" to use surfraw version, which opens duckduckgo/lite variant. read next two posts please.
EDIT: added few more keywords for searching map/image/news/video search on google. If sdcv is installed and working it can be used search offline dictionary through the same script (line is commented by default)
EDIT: now using arrays as per input by Alad

Last edited by Docbroke (2016-12-25 17:05:07)

Offline

#9 2016-12-23 20:34:50

Alad
Wiki Admin/IRC Op
From: Bagelstan
Registered: 2014-05-04
Posts: 2,407
Website

Re: Bash bookmarking script

If you're relying on variables to be expanded, use an array, not remove quotes from variables.

read -a foo
-browser="${foo[0]}" "${foo[@]:1]}"

And if you don't like something about surfraw, why not fix it instead of write a full replacement?


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby

Offline

#10 2016-12-24 02:53:36

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Re: Bash bookmarking script

I just read man page of surfraw and entire script of duckduckgo in /usr/lib/surfraw/duckduckgo.
What the script is doing is it assumes that javascript is not available so it opens lite version of duckduckgo. To tell it that javascript is avalable we need to supply -j option.
So now the line in script looks like

 *) duckduckgo -j -browser=$BROWSER $url $opts ;;

I will edit the script in previous post.

I don't get what you are trying to tell with array & examples. I am total noob, I just read bashguide, script examples on this thread/internet and try to create my own as per my needs. Can you give easier example?

Last edited by Docbroke (2016-12-24 02:58:22)

Offline

#11 2016-12-24 20:45:50

Alad
Wiki Admin/IRC Op
From: Bagelstan
Registered: 2014-05-04
Posts: 2,407
Website

Re: Bash bookmarking script

[archie@thinkpad ~]$ read foo <<< 'foo baz'
[archie@thinkpad ~]$ printf %s\\n $foo
foo # oops!
baz
[archie@thinkpad ~]$ printf %s\\n "$foo"
foo baz # quote preserves space
[archie@thinkpad ~]$ read -a foo <<< 'foo baz'
[archie@thinkpad ~]$ printf %s\\n $foo
foo # when referred to as a variable, only the first element is used
[archie@thinkpad ~]$ printf %s\\n ${foo[0]}
foo # more explicit notation of the above
[archie@thinkpad ~]$ printf %s\\n ${foo[@]}
foo # all elements
baz
[archie@thinkpad ~]$ printf %s\\n "${foo[@]}"
foo # how is this different? answer: foo baz vs. "foo" "baz"
baz
[archie@thinkpad ~]$ printf %s\\n "${foo[@]:1}"
baz # print from second element (1 when counted from 0) onwards
[archie@thinkpad ~]$ printf %s\\n "${foo[*]}"
foo baz # concatenation
[archie@thinkpad ~]$ printf %s\\n ${foo[*]}
foo # oops again
baz

In other words, less surprises when you use arrays, know their operators and quote everything. For more examples, see:

info bash

Last edited by Alad (2016-12-24 20:49:25)


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby

Offline

#12 2016-12-25 02:11:36

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Re: Bash bookmarking script

thanks Alad, updated the script in #2852, kindly review it again.

Last edited by Docbroke (2016-12-25 02:38:18)

Offline

#13 2016-12-25 14:21:59

Alad
Wiki Admin/IRC Op
From: Bagelstan
Registered: 2014-05-04
Posts: 2,407
Website

Re: Bash bookmarking script

$"{url[@]:1}"

Pretty sure you need the quote before the $...

"${url[@]:1}"

Last edited by Alad (2016-12-25 14:22:23)


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby

Offline

#14 2016-12-25 17:08:20

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Re: Bash bookmarking script

@Alad, that was a silly mistake, made during using find&replace function of vim (used as a editor in w3m). Script I am using on my laptop is alright and functioning well, so I didn't realize the mistake. Thanks for pointing out.

Offline

#15 2016-12-25 21:48:21

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Bash bookmarking script

Docbroke, looking at that complicated switch statement, I would probably stop trying to parse for URLs and simply fallback on passing everything to $BROWSER if it doesn't match a surfraw keyword.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#16 2016-12-26 02:52:46

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Re: Bash bookmarking script

Eschwartz wrote:

Docbroke, looking at that complicated switch statement, I would probably stop trying to parse for URLs and simply fallback on passing everything to $BROWSER if it doesn't match a surfraw keyword.

You may be right with browsers like chromium/firefox, but for w3m/lariza/surf that will simply give error when anything other than url is given to them. I cannot pass "best linux distro" to lariza. However if I replace "*) ..) line with something like "ddg) ..." I can pass everthing else to browser, but I will loose ability to input search term without keywords, as that will go straight to the browser. So now I have to input " ddg best linux distro", or which ever serch engine I want to use else it will go the browser.
I think my current setup works well as if I am using url that script fails to identify I can use ">" keyword, but that happens only in rare cases.

Offline

#17 2016-12-26 03:15:49

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Bash bookmarking script

If incompetent $BROWSER is incapable of doing something sane on arbitrary text input big_smile then clearly you should be prefixing arbitrary searches with that ddg keyword.

Currently your script falls all over the place on numerous URLs that don't conform to your highly fragile URL parsing. And you work around that by thinking ahead of time whether it will match your rules, and figuring out whether you need to place another keyword after the URL.
You must either precede all urls with the "https?://" scheme, or pray that it begins with the www subdomain, or assume it is one of four common top-level domains.
Additionally, you cannot perform a keyword search that begins with "http", because it is automatically assumed to be an URL and passed into arbitrary browsers that may not be able to handle search terms.

All this, just to avoid prefixing searches with the same keywords you expect of any other type of surfraw trigger?


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#18 2016-12-26 04:38:29

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Re: Bash bookmarking script

How does browsers detect that input is url or not?
Can you suggest how to parse url?
I did try to pass everything to browser if surfraw keyword doesn't match but I don't feel comfortable typing "ddg" almost every time. It is better to use ">" on occasions of having some odd url.

Offline

#19 2016-12-26 04:55:15

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Bash bookmarking script

Browsers have complex URL parsers the likes of which are difficult to reimplement in bash. Do whatever you want, just keep in mind that without a proper parser you really would be best off using keywords everywhere. Keywords are easy to test.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#20 2016-12-26 19:19:07

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Re: Bash bookmarking script

@Eschwartz, what do you think of this? I guess "*.*" will match any url, and it certainly doesn't match any keyword. At present I don't think I am going to search anything that matches "*.*", but for such cases when searchterm contains "." or when I want to search about some url (inplace of opening it), I have kept "ddg" and "google" as keywords.

#!/bin/bash

### DEPENDS ON ###
    # "surfraw"-for keyword based search, you will need /usr/lib/surfraw in your path, so add below line to your .bashrc (uncommented)
    # PATH=/usr/lib/surfraw:${PATH}
### CONFIGURATION ###
    # place your browser in BROWSER=? line
    ## only if not using w3m 
	# you can use your bookmarks text file with 1 url/line, put it in second "BOOKMARKS=?" field replacing /tmp/bookmarks, comment out first "BOOKMARKS=?" line & grep -o line
    # w3m users do not need to change BOOKMARKS=?
    # default script uses rofi, to use dmenu uncomment the line starting with dmenu and comment out previous line starting with rofi
### USE ###
    # enter text in rofi/dmenu field, it will be matched against bookmarks, <enter> to open selected bookmark
    # to search specific sites use keyword as first argument ( like go for google, wi for wikipedia, aw for archwiki etc.) > read the script to find out all keywords
    # if no keyword or url is used, entire argument will be searched with duckduckgo
    # url is identified with http/www/org/com/edu/in etc., for other urls use ">" as keyword elsed it will go to duckduckgo
    # to use enterd text directly (not the matching bookmark) use <C-enter> (rofi only)
    # to edit selected bookmark use <C-space> (rofi only)

BROWSER=lariza
# only for w3m bookmarks/ comment out if not using w3m
BOOKMARKS=~/.w3m/bookmark.html
HISTORY=~/.w3m/history

# convert .w3m/bookmarks to simple text with 1 url/line; comment out if not using w3m
grep -o 'http[^"]*' $BOOKMARKS > /tmp/bookmarks
# add w3m history to the list of bookmarks
# grep -o 'http[^"]*' $HISTORY >> /tmp/bookmarks

shopt -s lastpipe
# add your plain text bookmarks here (do not edit or comment out if using w3m bookmarks)
BOOKMARKS=/tmp/bookmarks
rofi -dmenu -location 1 -l 10 -width 100 -p $BROWSER: < "$BOOKMARKS" | read -a url
# dmenu -l 10 -p $BROWSER: < "$BOOKMARKS" | read -a url

[[ ! $url ]] && exit

duckimage() {
x=$@
$BROWSER "https://duckduckgo.com/?q=${x// /+}&ia=images&iax=1"
}
duckvideo() {
x=$@
$BROWSER "https://duckduckgo.com/?q=${x// /+}&ia=videos&iax=1"
}
case "${url[0]}" in
    *.*)   $BROWSER "${url[@]}" ;;
#    \>)      $BROWSER "${url[@]:1}" ;;
#    *www.*)  $BROWSER "${url[@]}" ;;
#    *.com*)  $BROWSER "${url[@]}" ;;
#    *.in*)   $BROWSER "${url[@]}" ;;
#    *.edu*)  $BROWSER "${url[@]}" ;;
#    *.org*)  $BROWSER "${url[@]}" ;;
    aw|awiki)   archwiki    -browser=$BROWSER "${url[@]:1}" ;;
    wi|wiki)    wikipedia   -browser=$BROWSER "${url[@]:1}" ;;
    imdb)	imdb        -browser=$BROWSER "${url[@]:1}" ;;
    aur)	aur         -browser=$BROWSER "${url[@]:1}" ;;
    pkg)	archpkg     -browser=$BROWSER "${url[@]:1}" ;;
    ddg)      duckduckgo -j -browser=$BROWSER "${url[@]:1}" ;;
    go|google)  google      -browser=$BROWSER "${url[@]:1}" ;;
    map)	google -m   -browser=$BROWSER "${url[@]:1}" ;;
#    image)	google -i   -browser=$BROWSER "${url[@]:1}" ;;   
    image) duckimage "${url[@]:1}" ;;   
#    video)	google -v   -browser=$BROWSER "${url[@]:1}" ;;   
    video) duckvideo "${url[@]:1}" ;;
    news)	google -n   -browser=$BROWSER "${url[@]:1}" ;;      
    yt|youtube)	youtube     -browser=$BROWSER "${url[@]:1}" ;;
    ebay)	ebay        -browser=$BROWSER "${url[@]:1}" ;;
    pubmed)	pubmed      -browser=$BROWSER "${url[@]:1}" ;;
    git|github)	github      -browser=$BROWSER "${url[@]:1}" ;;
#    def) notify-send -t 9999999 "$( sdcv --data-dir ~/dic/english/ "${url[@]:1}" )" ;;
    *)	 duckduckgo -j	    -browser=$BROWSER "${url[@]}" ;;
esac

Last edited by Docbroke (2016-12-27 00:24:29)

Offline

#21 2016-12-26 20:04:17

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Bash bookmarking script

I'm going to split this out; it has gone way beyond sharing a handy utility and is now a full-blown course in shell scripting...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#22 2016-12-27 00:15:47

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Bash bookmarking script

Sounds like a decent enough solution.

BTW, you just added a hardcoded $BROWSER in your new functions...


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#23 2016-12-27 00:27:30

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Re: Bash bookmarking script

Eschwartz wrote:

Sounds like a decent enough solution.

BTW, you just added a hardcoded $BROWSER in your new functions...

Edited to remove the hardcoding. Thanks for approval!

Offline

#24 2016-12-27 02:14:08

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Re: Bash bookmarking script

jasonwryan wrote:

I'm going to split this out; it has gone way beyond sharing a handy utility and is now a full-blown course in shell scripting...

You missed this

 mv /handy_commandline_utilities/${#2845-#2849} /bash_bookmarking_script/after #6

Offline

#25 2016-12-27 02:16:54

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Bash bookmarking script

Yeah, the discussion crossed the page barrier so I had to retrieve all the posts in two passes, which means that they all get renumbered. It was inevitable.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB