Giter VIP home page Giter VIP logo

sponge's Introduction

🧽 Sponge Releases

Discord Twitch Status

Don't you hate it when you spend half an hour searching for a command, finally find it and happily press Enter only to realize a couple of seconds later... it's not that one, it's another one you've entered two months ago, the one with the typo.

Ugh. Awful. Ungodly. Unproductive. Your day is ruined… unless you use Sponge.

Sponge quietly runs in the background and keeps your shell history clean from typos, incorrectly used commands and everything you don't want to store due to privacy reasons.

💾 Installation

Install with Fisher:

fisher install meaningful-ooo/sponge

🤖 System requirements

🕹️ Usage

Just use your shell as usual and enjoy typos-free history😎

Sponge will automatically filter out all failed commands unless they have been in the history before. The last 2 entries are always available so you can quickly fix a misspelled command.

Sponge won’t filter commands retroactively. If you don’t want previously mistyped commands clogging up your search results, clear the history once after Sponge installation:

history clear

⚙️ Settings

💩 Filter failed

By default Sponge will filter out all commands that don’t have 0 as an exit code. You can tweak which exit codes Sponge considers successful with sponge_successful_exit_codes variable:

set sponge_successful_exit_codes 0 127

If you wish to filter out all failed commands regardless of whether they already have been in the history or not, change sponge_allow_previously_successful variable:

set sponge_allow_previously_successful false

🕵🏻 Filter by regex

You can use the full power of regular expressions to filter out unwanted commands. Set sponge_regex_patterns variable and everything matched will be kept away from the history. For example, to filter out every command that contains IPv4 address, type:

set sponge_regex_patterns '(?:\d{1,3}\.){3}\d{1,3}'

🦥 Adjusting delay

By default Sponge delays purging of filtered command so you can always access the last 2 history entries. If you want to remove commands immediately or increase the delay, change sponge_delay variable:

set sponge_delay 5

⛔ Purge only on exit

Sometimes you want to ignore sponge_delay variable and access the whole history of the current session. In such cases you can instruct Sponge to purge entries only on shell exit with sponge_purge_only_on_exit variable:

set sponge_purge_only_on_exit true

💡 Did you know you can change settings only for the current session? Just add --global flag when setting any variable and it won't be preserved after shell exit.

🤓 Custom filters

Sponge works by invoking an array of filters. You can plug into this mechanism by defining your own filters.

Filter is simply a function with a specific call signature:

Argument Name Description
1 command The exact command that was entered
2 exit_code The exit code of the command
3 previously_in_history true or false flag indicating if the command has been in the history before

Return with exit status 0 to filter out provided command and anything else to keep the command in the history.

You can define your filter in config.fish or as a standalone function in fish functions folder.

Be mindful of what you put in filters, as they are run synchronously after each command execution and can slow down your prompt in case of compute-intensive tasks or network requests.

After that you need to register your filter with Sponge by adding its name in sponge_filters variable:

set --append sponge_filters my_awesome_filter

Make sure to append sponge_filters like in the example above unless you want to disable the built in filters:

©️ License

MIT

🏴‍☠️ 🏰 💎 Meaningful

We are the first ever blockchain state. More.

sponge's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

kevspa halostatue

sponge's Issues

Trigger only on shell exit

This may not be possible, but is there a way to trigger sponging for the commands run only after the shell is exited? I really like this feature, but I find myself scrolling back for commands that failed as I'm developing scripts, etc. Thanks for the great work!

Does not work

Title.
I install Sponge, I type wrong commands, and they all stay in history.

However, all of its related functions (like _sponge_on_prompt, _sponge_remove_from_history or sponge_filter_failed) are visible to Fish.
In fact, I can make Sponge work by manually executing _sponge_install and _sponge_on_prompt.

I tried clearing the Fish configuration from ~/.config, but it changed nothing.

Though I have to note that I didn't install Sponge the "traditional" way (i.e. via Fisher), but via Nix. However, I installed all the other extensions the same way, and they work fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.