Coder Social home page Coder Social logo

zsh-histdb-skim's Introduction

zsh-histdb-skim

This is a reimplementation of https://github.com/m42e/zsh-histdb-fzf in rust and using skim as a library.

Why

zsh-histdb-fzf works, but it is a bit quirky. It has for sure some flaws, regarding responsiveness and communication with processes. skim offers a fzf like behavior and is available as library in rust. It lacks some highlighting in the header, and has a bit different order/matching algorithm.

This should result in better performance, responsiveness and a more stable behavior.

Why rust?

skim is available in rust. I have never tried rust with a purpose before. I wanted to give it a try and learn something new.

How it works

Well, it accesses the zsh histdb. It lets you search on different levels.

What do you have to do?

Install the plugin, e.g. using zplug.

  zplug 'm42e/zsh-histdb-skim', from:github, at:main

It downloads the binary (if available) automatically. You can do manually by calling histdb-skim-download. It will be saved in ${XDG_DATA_HOME}/zsh-histdb-skim, alternatively ${HOME}/.local/share/zsh-histdb-skim. You can specify the directory manually by setting HISTDB_SKIM_PATH.

The download will happen if the executable is not there or the version is outdated (starting from v0.7.0). These checks happen when sourcing the script.

The plugin calls bindkey but some other plugins may overwrite. In this case you would have to do it yourself:

bindkey '^R' histdb-skim-widget

Additional information

By default the binary is downloaded

Building

cargo build --release
mkdir -p bin
mv target/release/zsh-histdb-skim bin

TODO

  • improve rust code

Apologies πŸ˜‰

While I stole the idea from myself, this is my first rust project ever. So I would be glad for tips and improvement PRs.

zsh-histdb-skim's People

Contributors

fyan-nz avatar jirutka avatar m42e avatar zegervdv avatar

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

Watchers

 avatar

zsh-histdb-skim's Issues

Not discovering binary.

So, after building the binary, the plugin is unable to find the binary. The default location is supposed to be `~/.local/share/zsh-histdb-skim/bin``, but it does not recognize the plugin there. I have also moved it to $PATH, which since it is not told to look there, it does not find it.

Just a point of information, that if you install this plugin with a plugin manager, such as zplug, then the binary will never be in the default location.

Finally, you didn't include BSD in your definitions of operating systems. Looks like a PR...

Typo in project’s About

- A zsh histb browser using skim. Implemented in rust. 
+ A zsh histdb browser using skim. Implemented in rust. 

Working out rough compatibility for OpenBSD

Discovered your plugin while reworking my shell to implement zi, and we both have to admit, rust is pretty damn cool. So, it works nicely, there is no issue there. It just outputs an error every time my shell is loaded, Could not find prebuild executable; Sorry, you have to do it yourself. πŸ˜• To which, I always mentally respond, "I did do it myself, what is the script talking about?" πŸ˜† The other thing is when I execute histdb-skim-get-os. I get nothing. 😟

So, I was wondering if we could find a way to resolve these issues.

Thanks.

compatibility with more plugin systems

could you rename the main script to zsh-histdb-skim.plugin.zsh? then more plugin systems can detect it.

thanks

(even for zplug, it should make the install command shorter)

Times are shown in UTC

I'm seeing that the times shown in the UI are in UTC timezone instead of my local one.
However, histdb query is showing correct times.

Commit Cargo.lock

Just tried to build this within nix using rustPlatform.buildRustPackage and that failed because the Cargo.lock is missing.
I saw that you removed the Cargo.lock, though I don't know why. Here it is recommended to commit the Cargo.lock

Results are much worse than zsh-histdb-fzf

zsh-histdb-skim finds results that fit much less well first before the results I want. For example, in a search for ls -alh the results are:

fzf: "14/04/2022 ls data/artifacts/SplitDatasetArtifact -alh"
skim: "14/04 cargo fmt --all --features sqlite -- -- check"

The reason seems to be the .nosort(true) option in main.rs. Removing that option, the results are much better

Automatic download fails when installing system-wide

First I'd like to thank you for this amazing plugin, you saved me some hours writing a proper histdb integration myself :D

I've installed this plugin system wide to /usr/share/zsh/zsh-histdb-skim/, which unfortunately causes my regular user to try downloading the binary to that directory. I believe it would be far better if your program would store the binary in the proper XDG directory in the user's home. So in bash/zsh syntax this would be ${XDG_DATA_HOME:-$HOME/.local/share}/zsh-histdb-skim/.

If i'm not mistaken, the binary will also never be updated once it exists, correct? How are you planning on automatically delivering updates?

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.