Sunday, May 5, 2024
6
rated 0 times [  6] [ 0]  / answers: 1 / hits: 535  / 2 Years ago, sat, april 16, 2022, 10:32:32

I would like to create an alias with the function to perform a DuckDuckGo search with W3M via the Command Line Interface (CLI).


I have already created the alias and the DuckDuckGo search engine is called. However, I would also like to enter a search keyword after the alias in the CLI and I do not know how to do that.
Example:


alias duckit="w3m https://lite.duckduckgo.com/lite/"

When I enter the command duckit in the CLI, this alias calls the DuckDuckGo search engine and opens the web page.
But I want the alias to also enter the search keyword in DuckDuckGo and show me the results.


So I tried adding ?q= at the end of the alias above:


alias duckit="w3m https://lite.duckduckgo.com/lite/?q="

However, running it as follows does not work:


duckit test

What do I need to do?


More From » command-line

 Answers
3

You cannot use an alias if you need to pass parameters to it, you need to use a function instead. Add this to your ~/.bashrc file:


duckit(){
w3m https://lite.duckduckgo.com/lite/?q="$@"
}

Now open a new terminal and try duckit test.


[#1574] Monday, April 18, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
imonove

Total Points: 82
Total Questions: 113
Total Answers: 106

Location: Saint Vincent and the Grenadines
Member since Wed, Nov 3, 2021
3 Years ago
;