All Projects → AlexanderThaller → hstdb

AlexanderThaller / hstdb

Licence: MIT License
Better history management for zsh. Based on ideas from https://github.com/larkery/zsh-histdb.

Programming Languages

rust
11053 projects
shell
77523 projects

Projects that are alternatives of or similar to hstdb

Resh
Rich Enhanced Shell History - Contextual shell history for zsh and bash
Stars: ✭ 310 (+1140%)
Mutual labels:  zsh, history
Dstask
Single binary terminal-based TODO manager with git-based sync + markdown notes per task
Stars: ✭ 431 (+1624%)
Mutual labels:  zsh, sync
atuin
🐢 Magical shell history
Stars: ✭ 1,295 (+5080%)
Mutual labels:  zsh, history
Zsh Histdb
A slightly better history for zsh
Stars: ✭ 801 (+3104%)
Mutual labels:  zsh, history
Notes
📝 Simple delightful note taking, with more unix and less lock-in.
Stars: ✭ 939 (+3656%)
Mutual labels:  zsh, sync
Bashhub Server
Private cloud shell history. Open source server for bashhub https://github.com/rcaloras/bashhub-client
Stars: ✭ 189 (+656%)
Mutual labels:  zsh, history
History Search Multi Word
Multi-word, syntax highlighted history searching for Zsh
Stars: ✭ 314 (+1156%)
Mutual labels:  zsh, history
Zsh History To Fish
Bring your ZSH history to Fish shell.
Stars: ✭ 23 (-8%)
Mutual labels:  zsh, history
Bashhub Client
☁️ Bash history in the cloud. Indexed and searchable.
Stars: ✭ 858 (+3332%)
Mutual labels:  zsh, history
Hstr Rs
hstr, but with paging
Stars: ✭ 122 (+388%)
Mutual labels:  zsh, history
Hstr
bash and zsh shell history suggest box - easily view, navigate, search and manage your command history.
Stars: ✭ 2,909 (+11536%)
Mutual labels:  zsh, history
zsh-ssh-agent
Ssh-agent management for zsh
Stars: ✭ 19 (-24%)
Mutual labels:  zsh
autorice
Autorice 9001 ~ Simple and fast arch setup in minutes
Stars: ✭ 55 (+120%)
Mutual labels:  zsh
docker-aws-s3-sync
Docker container to sync a folder to Amazon S3
Stars: ✭ 21 (-16%)
Mutual labels:  sync
zsh-completions
Yet another zsh completion sources library. Fork, fix and written by me.
Stars: ✭ 80 (+220%)
Mutual labels:  zsh
dotfiles
🚀 tmux, ohmyzsh, powerlevel10k, neovim 🔧
Stars: ✭ 24 (-4%)
Mutual labels:  zsh
dotfiles
cross-platform (linux (arch), macos, android (termux), windows (WSL)) dotfiles and scripts, using yadm
Stars: ✭ 17 (-32%)
Mutual labels:  zsh
iwata-asks-downloader
Tool to download Iwata Asks interviews (none of which are stored in this repo)
Stars: ✭ 17 (-32%)
Mutual labels:  history
config
Fig's integrations with bash, zsh, fish, ssh, and tmux. Also contains Fig's installation and update scripts. Finally, this repo is the root of the .fig folder that is installed on your computer when you download Fig!
Stars: ✭ 44 (+76%)
Mutual labels:  zsh
sync-db
Utility to synchronize relational database objects across databases.
Stars: ✭ 15 (-40%)
Mutual labels:  sync

hstdb

Build Status crates.io

Better history management for zsh. Based on ideas from https://github.com/larkery/zsh-histdb.

Licensed under MIT.

It was mainly written because the sqlite merging broke a few to many times for me and using a sqlite database seemed overkill.

The tool is just writing CSV files for each host which makes syncing them via git pretty painless.

Has pretty much the same feature set as zsh-histdb:

  • Start and stop time of the command
  • Working directory in which the command was run
  • Hostname of the machine the command was run in
  • Unique session ids based on UUIDs
  • Exit status of the command
  • Import from zsh histfile and zsh-histdb sqlite database

Installation

You can either install the right binary from the releases page or run:

cargo install hstdb

Archlinux

Install from the aur: https://aur.archlinux.org/packages/hstdb/

First Start

After you installed hstdb you need to start the server:

hstdb server

By default the server will run in the foreground.

To stop the server you can run the following:

hstdb stop

Or send SIGTERM/SIGINT (Ctrl+C) to stop the server.

You can also use the systemd unit file in hstdb.service which you can copy to "$HOME/.config/systemd and enable/start with the following:

systemctl --user daemon-reload
systemctl --user enable hstdb.service
systemctl --user start hstdb.service

After that you can add the following to your .zshrc to enable hstdb for you shell.

eval "$(hstdb init)"

You can run that in your current shell to enable hstdb or restart your shell.

Usage

Help output of default command:

hstdb 2.0.0

USAGE:
    hstdb [FLAGS] [OPTIONS] [SUBCOMMAND]

FLAGS:
        --all-hosts
            Print all hosts

        --disable-formatting
            Disable fancy formatting

        --filter-failed
            Filter out failed commands (return code not 0)

    -h, --help
            Prints help information

        --hide-header
            Disable printing of header

    -i, --in
            Only print entries that have been executed in the current directory

        --no-subdirs
            Exclude subdirectories when filtering by folder

        --show-duration
            Show how long the command ran

        --show-host
            Print host column

        --show-pwd
            Show directory in which the command was run

        --show-session
            Show session id for command

        --show-status
            Print returncode of command

    -V, --version
            Prints version information


OPTIONS:
    -c, --command <command>
            Only print entries beginning with the given command

    -t, --text <command-text>
            Only print entries containing the given regex

        --config-path <config-path>
            Path to the socket for communication with the server [env: HISTDBRS_CONFIG_PATH=]  [default:
            /home/athaller/.config/hstdb/config.toml]
    -d, --data-dir <data-dir>
            Path to folder in which to store the history files [default: /home/athaller/.local/share/hstdb]

    -e, --entries-count <entries-count>
            How many entries to print [default: 25]

        --find-status <find-status>
            Find commands with the given return code

    -f, --folder <folder>
            Only print entries that have been executed in the given directory

        --hostname <hostname>
            Filter by given hostname

        --session <session>
            Filter by given session


SUBCOMMANDS:
    bench
            Run benchmark against server

    disable
            Disable history recording for current session

    enable
            Enable history recording for current session

    help
            Prints this message or the help of the given subcommand(s)

    import
            Import entries from existing histdb sqlite or zsh histfile

    init
            Print out shell functions needed by histdb and set current session id

    precmd
            Finish command for current session

    server
            Start the server

    session_id
            Get new session id

    stop
            Stop the server

    zshaddhistory
            Add new command for current session

The most basic command ist just running hstdb without any arguments:

» hstdb
 tmn    cmd
 14:28  cargo +nightly install --path .

That will print the history for the current machine. By default only the last 25 entries will be printed.

Git

hstdb was written to easily sync the history between multiple machines. For that hstdb will write separate history files for each machine.

If you want to sync between machines go to the datadir (default is $HOME/.local/share/hstdb) and run the following commands:

git init
git add :/
git commit -m "Initial commit"

After that you can configure origins and start syncing the files between machines. There is no autocommit/autosync implemented as we don't want to have commits for each command run. This could be changed in the future.

Configuration

There is also a way to configure hstdb. By default the configuration is stored under $HOME/.config/hstdb/config.toml. A different path can be specified using the --config-path option.

The default configuration looks like this:

# When true will not save commands that start with a space.
# Default: true
ignore_space = true

# The log level to run under.
# Default: Warn
log_level = "Warn"

Import

zsh-histdb

» histdb import histdb -h
hstdb-import-histdb 0.1.0
Import entries from existing histdb sqlite file

USAGE:
    hstdb import histdb [OPTIONS]

FLAGS:
    -h, --help
            Prints help information


OPTIONS:
    -d, --data-dir <data-dir>
            Path to folder in which to store the history files [default: $HOME/.local/share/hstdb]

    -i, --import-file <import-file>
            Path to the existing histdb sqlite file [default: $HOME/.histdb/zsh-history.db]

If the defaults for the data-dir and the import-file are fine you can just run the following command:

histdb import histdb

This will create CSV files for each hostname found in the sqlite database. It will create a UUID for each unique session found in sqlite so command run in the same session should still be grouped together.

zsh histfile

» histdb import histfile -h
hstdb-import-histfile 0.1.0
Import entries from existing zsh histfile

USAGE:
    hstdb import histfile [OPTIONS]

FLAGS:
    -h, --help
            Prints help information


OPTIONS:
    -d, --data-dir <data-dir>
            Path to folder in which to store the history files [default: $HOME/.local/share/hstdb]

    -i, --import-file <import-file>
            Path to the existing zsh histfile file [default: $HOME/.histfile]

If the defaults for the data-dir and the import-file are fine you can just run the following command:

histdb import histfile

As the information stored in the histfile is pretty limited the following information will be stored:

  • time_finished will be parsed from the histfile
  • result (exit code) will be parsed from the histfile
  • command will be parsed from the histfile
  • time_start will be copied over from time_finished
  • hostname will use the current machines hostname
  • pwd will be set to the current users home directory
  • session_id will be generated and used for all commands imported from the histfile
  • user will use the current user thats running the import

Contribution

I'm happy with how the tool works for me so I won't expand it further but contributions for features and fixes are always welcome!

Alternatives

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].