Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
herzrasen committed Jan 5, 2023
1 parent 3c8605d commit 403f016
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 8 deletions.
136 changes: 136 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,139 @@
# hist - Improved shell history

`hist` aims to be an improvement to the standard history command on Linux
and Mac based systems (currently only zsh is supported).

Command history is stored in an `sqlite3` database (located in the user's
XDG DataDir).

Certain commands can be ignored by defining exclude patterns in the config file
(located in the user's XSD ConfigDir).

An interactive search mode is bound to the `ctrl-c` command. It used a fuzzy
search mode to select a command from your command history.

## Config

By default, config is stored in `XDG_CONFIG_HOME/hist/config.yml`.

Currently only specifying path's to be excluded is supported.

```yaml
---
patterns:
excludes:
- ^ls .*
- ^ll.*
- ^cd .*
- ^rm .*
```
This excluded all commands starting with `ls`, `ll`, `cd` and `rm` from being added to history.
When adding new exclude rules, the current config can be tidied up by using `hist tidy`.

## Usage

````shell
Usage: hist [--config CONFIG] <command> [<args>]

Options:
--config CONFIG [default: ~/.config/hist/config.yml]
--help, -h display this help and exit

Commands:
delete Delete commands from history
get Get a command by it's index'
import Import commands from a legacy history file
list List commands
record Record a new command
search Start the interactive fuzzy selection mode
stats Show some statistics
tidy Apply exlude patterns to clean up the hist database
````

### Delete

Delete one or more entries from the database.

```shell
Usage: hist delete [--id ID] [--updated-before UPDATED-BEFORE] [--pattern PATTERN]
Options:
--id ID, -i ID
--updated-before UPDATED-BEFORE, -u UPDATED-BEFORE
--pattern PATTERN, -p PATTERN
Delete all records matching the pattern
```

### Get

Get a command from the database by index. This is used when traversing through
history using `arrow up` and `arrow down` keys.

```shell
Usage: hist get [--index INDEX]
Options:
--index INDEX
```

### Import

```shell
Usage: hist import [PATH]
Positional arguments:
PATH
```
### List

```shell
Usage: hist list [--by-count] [--reverse] [--no-count] [--no-last-update] [--with-id] [--limit LIMIT]
Options:
--by-count
--reverse
--no-count
--no-last-update
--with-id
--limit LIMIT, -l LIMIT [default: -1]
```
### Record

```shell
Usage: hist record [COMMAND]
Positional arguments:
COMMAND
```

### Search

```shell
Usage: hist search
```

### Stats

```shell
Usage: hist stats
```

### Tidy

```shell
Usage: hist tidy
```

## Building and installing

Currently only building the binary yourself is supported.

```shell
git clone https://github.com/herzrasen/hist.git
cd hist
make && sudo make install
```

Also make sure that you source the shell script in your
`.zshrc`
16 changes: 8 additions & 8 deletions args/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ type StatsCmd struct {
}

type Args struct {
Delete *DeleteCmd `arg:"subcommand:delete"`
Get *GetCmd `arg:"subcommand:get"`
Import *ImportCmd `arg:"subcommand:import"`
List *ListCmd `arg:"subcommand:list"`
Record *RecordCmd `arg:"subcommand:record"`
Search *SearchCmd `arg:"subcommand:search"`
Stats *StatsCmd `arg:"subcommand:stats"`
Tidy *TidyCmd `arg:"subcommand:tidy"`
Delete *DeleteCmd `arg:"subcommand:delete" help:"Delete commands from history"`
Get *GetCmd `arg:"subcommand:get" help:"Get a command by it's index'"`
Import *ImportCmd `arg:"subcommand:import" help:"Import commands from a legacy history file"`
List *ListCmd `arg:"subcommand:list" help:"List commands"`
Record *RecordCmd `arg:"subcommand:record" help:"Record a new command"`
Search *SearchCmd `arg:"subcommand:search" help:"Start the interactive fuzzy selection mode"`
Stats *StatsCmd `arg:"subcommand:stats" help:"Show some statistics"`
Tidy *TidyCmd `arg:"subcommand:tidy" help:"Apply exlude patterns to clean up the hist database"`
Config string `arg:"--config" default:"~/.config/hist/config.yml"`
}

0 comments on commit 403f016

Please sign in to comment.