squeeze enables to extract rich information from any text (raw, JSON, HTML, YAML, etc).
Currently supported:
See integrations for some practical uses. Continue reading for the install and getting started instructions.
This method requires the Rust toolchain to be installed on your machine.
git clone --depth=1 https://github.com/aymericbeaumet/squeeze.git /tmp/squeeze
cargo install --path=/tmp/squeeze/squeeze-cli
Let's start by extracting a URL, squeeze
expects the text to be searched on
its standard input, with the results being placed on its standard output:
echo 'lorem https://github.com ipsum' | squeeze -1 --url
https://github.com
The
-1
flag allows to immediately abort after one result has been found.
If you want to print all the URLs, just omit the -1
flag:
squeeze --url << EOF
this a domain: github.com, but this is a url: https://aymericbeaumet.com
this is some markdown: [link](https://wikipedia.com)
EOF
https://aymericbeaumet.com
https://wikipedia.com
It is also possible to extract other types of information, like codetags
(TODO:
, FIXME:
, etc). The usage remains very similar:
squeeze --codetag=todo << EOF
// TODO: implement the main function
fn main {}
EOF
TODO: implement the main function
Note that for convenience some aliases are defined. In this case, you can use
--todo
instead of--codetag=todo
. In the same vein,--url
is an alias to limit the search to specific URI schemes.
It is possible to enable several finders at the same time, they will be run sequentially for each line:
squeeze --uri=http,https --codetag=todo,fixme << EOF
// TODO: update with a better example
// FIXME: all of https://github.com/aymericbeaumet/squeeze/issues
// Some random comment to be ignored
ftp://localhost
http://localhost
EOF
TODO: update with a better example
FIXME: all of https://github.com/aymericbeaumet/squeeze/issues
https://github.com/aymericbeaumet/squeeze/issues
http://localhost
This getting started should give you an overview of what's possible with
squeeze
. Have a look at all the possibilities with squeeze --help
.
Integrations with some popular tools.
Press Enter
in visual mode to extract the first URL from the current
selection and open it:
" ~/.vimrc
vnoremap <silent> <CR> :<C-U>'<,'>w !squeeze -1 --url --open<CR><CR>
Press Enter
in copy mode to extract the first URL from the current selection
and open it:
# ~/.tmux.conf
bind -T copy-mode-vi enter send -X copy-pipe-and-cancel "squeeze -1 --url --open"
Define a urls
function to list all the URLs in your shell history:
# ~/.bashrc ~/.zshrc
urls() { fc -rl 1 | squeeze --url | sort -u; }
echo 'http://localhost' | cargo run -- --url
cargo test
watchexec --clear --restart 'cargo test'