Skip to content

haaag/GoURL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔗 GoURL

✨ do not use regex 🤡

MadeWithGo

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 terminal with externalpipe patch to read/pipe current visible text to this program.

Using the option -c, --copy or -o, --open will display the items in 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
  • Copy to clipboard
  • Open with xdg-open
  • Custom regex search
  • Add index to URLs found
  • Limit number of items

⚡️Requirements

  • Go v1.21.3 or higher

📦 Build

# clone the repo
$ git clone 'https://github.com/haaag/GoURL' && cd GoURL

# use make to build
$ make

Binary can be found in GoURL/bin.

📦 Installation

# use make to build
$ make

# install on system wide
$ sudo make install

# or use a symlink
$ ln -sf $PWD/bin/gourl ~/.local/bin/

Uninstall from system, use sudo make uninstall or remove symlink with rm ~/.local/bin/gourl

🚀 Usage

$ gourl -h
Extract URLs from STDIN

Usage:
  gourl [options]

Options:
  -c, --copy        Copy to clipboard
  -o, --open        Open with xdg-open
  -n, --no-urls     Ignore URLs
  -e, --email       Extract emails
  -E, --regex       Custom regex search
  -l, --limit       Limit number of items
  -i, --index       Add index to URLs found
  -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 -n -e --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.

# 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 - Designed to integrate with the "mutt" mailreader
  • urlview - Extract URLs from a text file and allow the user to select via a menu

About

Extract URLs from STDIN

Resources

Stars

Watchers

Forks

Packages

No packages published