mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-23 02:35:38 +01:00
Merge 4d969fde5d into e3e468d138
This commit is contained in:
commit
e943f502b5
1 changed files with 46 additions and 2 deletions
|
|
@ -33,7 +33,7 @@ function web_search() {
|
|||
packagist "https://packagist.org/?query="
|
||||
gopkg "https://pkg.go.dev/search?m=package&q="
|
||||
chatgpt "https://chatgpt.com/?q="
|
||||
reddit "https://www.reddit.com/search/?q="
|
||||
# for the new reddit search go below at row 67
|
||||
ppai "https://www.perplexity.ai/search/new?q="
|
||||
)
|
||||
|
||||
|
|
@ -62,6 +62,50 @@ function web_search() {
|
|||
open_command "$url"
|
||||
}
|
||||
|
||||
# example usage: reddit swaywm (search all subreddits for swaywm)
|
||||
# example usage: reddit --sr unixporn swaywm (search only unixporn subreddit for swaywm) -> https://www.reddit.com/r/unixporn/search?q=swaywm
|
||||
|
||||
function reddit_search() {
|
||||
emulate -L zsh
|
||||
local url="https://www.reddit.com"
|
||||
local query=""
|
||||
local subreddit=""
|
||||
|
||||
# if the user pass "--sr <subreddit name>" as first argument
|
||||
# then the second argument is the subreddit name
|
||||
if [[ "$1" == "--sr" ]]; then
|
||||
subreddit="$2"
|
||||
query="${@[3,-1]}"
|
||||
else
|
||||
query="${@[1,-1]}"
|
||||
fi
|
||||
|
||||
# if query is empty, remove the search query
|
||||
if [[ -z "$query" ]]; then
|
||||
query=""
|
||||
fi
|
||||
|
||||
# if subreddit is empty, search all subreddits
|
||||
# but if query is empty, remove the search query
|
||||
if [[ -z "$subreddit" ]]; then
|
||||
if [[ -z "$query" ]]; then
|
||||
url="$url"
|
||||
else
|
||||
url="$url/search?q=$(omz_urlencode -P $query)"
|
||||
fi
|
||||
|
||||
else
|
||||
# if subreddit is not empty, search only that subreddit
|
||||
if [[ -z "$query" ]]; then
|
||||
url="$url/r/$subreddit"
|
||||
else
|
||||
url="$url/r/$subreddit/search?q=$(omz_urlencode -P $query)"
|
||||
fi
|
||||
fi
|
||||
|
||||
open_command "$url"
|
||||
}
|
||||
|
||||
|
||||
alias bing='web_search bing'
|
||||
alias brs='web_search brave'
|
||||
|
|
@ -89,7 +133,7 @@ alias npmpkg='web_search npmpkg'
|
|||
alias packagist='web_search packagist'
|
||||
alias gopkg='web_search gopkg'
|
||||
alias chatgpt='web_search chatgpt'
|
||||
alias reddit='web_search reddit'
|
||||
alias reddit='reddit_search'
|
||||
alias ppai='web_search ppai'
|
||||
|
||||
#add your own !bang searches here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue