Skip to content

Commit

Permalink
misc: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchristiansen committed Oct 23, 2022
0 parents commit 6213043
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Adam Christiansen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Plecostomus

A simple command history filter for the
[fish shell](https://github.com/fish-shell/fish-shell).

## Features

- Use regex filters to prevent commands from being saved in the command
history.
- Out of the box, commands that begin with one or more spaces are ignored.
- That's it - nothing else!

## Requirements

* [fish](https://github.com/fish-shell/fish-shell) (3.0.0 or higher)

## Installation

### Using [Fisher](https://github.com/jorgebucaran/fisher)

```sh
fisher install adamchristiansen/plecostomus
```

## Configuration

Filters can be added by modifying the `plecostomus_regex_patterns` universal
variable, which is an array of regex patterns to ignore. By default it is

```sh
set -U plecostomus_regex_patterns '^ +'
```

## Alternatives

This plugin is simple by design, and supports only regex filtering. It is
simple and fast. If more features are needed, consider using:

- [Sponge](https://github.com/meaningful-ooo/sponge)
23 changes: 23 additions & 0 deletions conf.d/plecostomus.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set -g plecostomus_version 1.0.0

# The default ignore patterns
if not set -qU plecostomus_regex_patterns
set -U plecostomus_regex_patterns '^ +'
end

# Load the handlers
functions --query __plecostomus_preexec __plecostomus_postexec

function __plecostomus_install --on-event plecostomus_install
set -g __plecostomus_command ''
end

function __plecostomus_update --on-event plecostomus_update
# Nothing to do
end

function __plecostomus_uninstall --on-event plecostomus_uninstall
set -eU plecostomus_regex_patterns
set -eg __plecostomus_command
set -eg plecostomus_version
end
9 changes: 9 additions & 0 deletions functions/__plecostomus_postexec.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function __plecostomus_postexec --on-event fish_postexec
for pattern in $plecostomus_regex_patterns
if builtin string match -rq -- $pattern $__plecostomus_command
builtin history delete --case-sensitive --exact -- $__plecostomus_command
break
end
end
builtin history save
end
3 changes: 3 additions & 0 deletions functions/__plecostomus_preexec.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function __plecostomus_preexec -e fish_preexec -a command
set -g __plecostomus_command $command
end

0 comments on commit 6213043

Please sign in to comment.