diff --git a/README.md b/README.md index 2dcdf9c..e571fba 100644 --- a/README.md +++ b/README.md @@ -30,13 +30,31 @@ Now if you run `hishtory query` on first computer, you can automatically see the ## Features -### Advanced Queries +### Querying -### Export +`hishtory query` is the main interface for searching through your shell history. See some below annotated queries: + +| Command | Explanation | +|---|---| +| `hishtory query psql` | Find all commands containing `psql` | +| `hishtory query psql db.example.com` | Find all commands containing `psql` and `db.example.com` | +| `hishtory query docker hostname:my-server` | Find all commands containing `docker` that were run on the computer with hostname `my-server` | +| `hishtory query nano user:root` | Find all commands containing `nano` that were run as `root` | +| `hishtory query exit_code:127` | Find all commands that exited with code `127` | +| `hishtory query service before:2022-02-01` | Find all commands containing `service` run before February 1st 2022 | +| `hishtory query service after:2022-02-01` | Find all commands containing `service` run after February 1st 2022 | + +For true power users, you can query via SQL via `sqlite3 ~/.hishtory/.hishtory.db`. + +In addition, `hishtory export` dumps all commands to stdout separated by a single line. This can be useful for certain advanced use cases. ### Enable/Disable -### update +If you want to temporarily turn on/off hishtory recording, you can do so via `hishtory disable` (to turn off recording) and `hishtory enable` (to turn on recording). You can check whether or not `hishtory` is enabled via `hishtory status`. + +### Updating + +To update `hishtory` to the latest version, just run `hishtory update` to transparently download and apply the latest update. ## Design @@ -50,4 +68,6 @@ Now if you run `hishtory query` on first computer, you can automatically see the * zsh support * mac support -* automatic test running in github actions \ No newline at end of file +* automatic test running in github actions +* support for filtering out items in a search query via `-foo` +* support for verifying the attestations tied to updates \ No newline at end of file diff --git a/client/data/data.go b/client/data/data.go index f981b74..3b6e765 100644 --- a/client/data/data.go +++ b/client/data/data.go @@ -167,6 +167,7 @@ func Search(db *gorm.DB, query string, limit int) ([]*HistoryEntry, error) { case "hostname": tx = tx.Where("instr(hostname, ?) > 0", val) case "cwd": + // TODO: Can I make this support querying via ~/ too? tx = tx.Where("instr(current_working_directory, ?) > 0", val) case "exit_code": tx = tx.Where("exit_code = ?", val) diff --git a/client/lib/lib.go b/client/lib/lib.go index 9b2cc4d..34827c5 100644 --- a/client/lib/lib.go +++ b/client/lib/lib.go @@ -400,6 +400,7 @@ func Update(url string) error { if err != nil { return fmt.Errorf("failed to unlink %s: %v", path.Join(homedir, shared.HISHTORY_PATH, "hishtory"), err) } + // TODO: Check the SLSA attestation before installing cmd = exec.Command("/tmp/hishtory-client", "install") err = cmd.Run() if err != nil {