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-cliLet'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 --urlhttps://github.com
The
-1flag 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)
EOFhttps://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 {}
EOFTODO: implement the main function
Note that for convenience some aliases are defined. In this case, you can use
--todoinstead of--codetag=todo. In the same vein,--urlis 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
EOFTODO: 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 -- --urlcargo test
watchexec --clear --restart 'cargo test'