https://github.com/mateconpizza/gourl
Extract URLs from STDIN | ✨ do not use regex 🤡
https://github.com/mateconpizza/gourl
mutt neomutt st-terminal suckless suckless-terminal urlscan urlview
Last synced: 12 months ago
JSON representation
Extract URLs from STDIN | ✨ do not use regex 🤡
- Host: GitHub
- URL: https://github.com/mateconpizza/gourl
- Owner: mateconpizza
- Created: 2024-03-18T16:09:02.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2025-01-17T02:44:40.000Z (over 1 year ago)
- Last Synced: 2025-06-06T11:09:11.297Z (about 1 year ago)
- Topics: mutt, neomutt, st-terminal, suckless, suckless-terminal, urlscan, urlview
- Language: Go
- Homepage:
- Size: 68.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
🔗 GoURL
✨ do not use regex 🤡


**GoURL** is a small `Golang` program that reads `URLs` and `email` addresses from standard input `(STDIN)`
You can use any **terminal** that supports piping visible text to external programs **_(alacritty, kitty, wezterm, etc)_**.
I'm using [st](https://st.suckless.org/) terminal with [externalpipe](https://st.suckless.org/patches/externalpipe/) patch to `read/pipe` current visible text to this program.
Using the option `-c, --copy`, `-o, --open` or `-x, --exec` will display the items in [dmenu](https://tools.suckless.org/dmenu/)
Without flags, prints `URLs` found to standard output `(STDOUT)`, **_you can pipe it to your preferred menu or launcher_**.
### ✨ Features
- Extract URLs from `STDIN`
- Choose items with `dmenu`
- Ignore `duplicates`
- `Execute command` with selected items
- `Copy` to clipboard
- `Open` with `xdg-open`
- Custom `regex` search
- Add `index` to URLs found
- Limit number of items
### ⚡️Requirements
- [Go](https://golang.org/) >= `v1.21.3`
- [dmenu](https://tools.suckless.org/dmenu/) `optional`
### 🧰 Build
```bash
# clone the repo
$ git clone 'https://github.com/haaag/GoURL' && cd GoURL
# use make to build
$ make
```
**Binary can be found in `GoURL/bin/gourl`**
### 📦 Installation
```bash
# use make to build
$ make
# install on system wide
$ sudo make install
# or use a symlink
$ ln -sf $PWD/bin/gourl ~/.local/bin/
```
#### 🗑️ Uninstall
- System: use `sudo make uninstall`
- User: remove symlink with `rm ~/.local/bin/gourl`
### 🚀 Usage
```bash
$ gourl -h
Extract URLs from STDIN
Usage:
gourl [options]
Options:
-c, --copy Copy to clipboard
-o, --open Open with xdg-open
-u, --urls Extract URLs (default: true)
-e, --email Extract emails (prefix: "mailto:")
-E, --regex Custom regex search
-x, --exe Execute command with all search results as arguments
-l, --limit Limit number of items
-i, --index Add index to URLs found
-p, --prompt Prompt for dmenu
-a, --args Args for dmenu
-V, --version Output version information
-v, --verbose Verbose mode
-h, --help Show this message
$ gourl -c < urls.txt
# or
$ cat urls.txt | gourl -c
# extract only emails
$ gourl --url=false --email --limit 1 < data.txt
# example@email.com
# with index
$ gourl -i -l 10 < urls.txt
# [1] https://www.example.org
# [2] https://www.example.com
# ...
```
### 🚩 Using `-E` flag
The flag `-E` can be use for `custom regex`, like in `grep`.
```bash
# list existing remotes
git remote -v | gourl -E '((git|ssh|http(s)?)|(git@[\w\.]+))(:(//)?)([\w\.@\:/\-~]+)(\.git)(/)?'
# git@github.com:xxxxx/zzzzz.git
```
### ⭐ Related projects
- [urlscan](https://github.com/firecat53/urlscan) - Designed to integrate with the "mutt" mailreader
- [urlview](https://github.com/sigpipe/urlview) - Extract URLs from a text file and allow the user to select via a menu