Hacker News new | past | comments | ask | show | jobs | submit login
Simple command-line snippet manager, written in Go (github.com/knqyf263)
144 points by enrico50 on March 13, 2017 | hide | past | favorite | 21 comments



This is cool. Also, there is one little trick you can do to make your shell history easier to search. You can comment your commands and then search via comments:

  % big hairy command here # foo the bars!
Then you can history search for 'foo' or whatnot. That doesn't totally obviate the need for a tool like this. I plan on checking it out.


Borg is similar, but it saves the snippets to a centralized* server: https://github.com/ok-borg/borg

There is also a web interface https://ok-b.org/

Anyone can edit the public snippets (only bash for now, because it is such an obvious usecase), but private ones are coming too.

The plan is provide a way to save and search snippets from anywhere, terminal, web, phone, whatever.

It is also written in Go.

Edit: the mobile version of the site is not too responsive, but a new version of the UI is coming :)

*Edit 2: You can also self host the server/frontend yourself and change your terminal client to point to your own.


Your comment made me decide to check out borg,

But so far I've been unable to get it working in any way- I've submitted a github issue.

Speaking of github- any chance we can have other login mechanisms for the frontend? I do so loathe having external dependencies.


Yes, login with Google at the very least is planned.

And yeah, there is an issue on some systems with dependencies of a go package. We are going to fix that, sorry.

Thanks for the issue.


Not too interested in the snippet manager, but when I was watching the demo movie, I noticed the author doing inline shell variable expansion. It never even occurred to me that shells could do that. Wish I had known about this years ago.

On bash, it's M-C-e where the Escape key can serve as the "M" portion. Also, M-r to clear the command-line, which I could also have used many times. Bash docs: https://www.gnu.org/software/bash/manual/html_node/Miscellan...


The day we know a language has made it is the day people no longer feel the need to suffix "written in X" to attract clicks.

This applies to Go, Rust, whatever. I'd love to see future projects stand on their own merits and be pleasantly surprised when discovering the source language on my own.


It can make a difference. For example, if this was written in ruby I might not bother using. On every device I'd have to get the correct ruby environment setup, install any dependent gems, and make sure if I have the gem path set correctly.

If it's written in go I know I can drop a static binary in my PATH and be done.


Yeah ok, thats a good point.


That's cool! I was thinking of doing something similar a few weeks ago. I settled on using tools I knew well to just achieve what I needed quickly. I use tmux and emacs. I run a tmux session with a window which has a top and bottom pane. Top pane shows a shell, and bottom pane shows emacs. Thanks to tmux, I can send keystrokes to a different pane. With emacs, I tell tmux to send the current line of characters to the top pane. In the emacs session, I have open a help.org file, where I organize some commands. For some reason, this worked with tmux 2.1 but not with tmux 2.3:

    (defun send-command-to-cli () (interactive)
      (let ((current 0)
        (the-command "")
        (start 0)
        (end 0))
        (setq current (point))
        (org-beginning-of-line)
        (setq start (point))
        (org-end-of-line)
        (setq end (point))
        (goto-char current)
        (setq the-command (concat
          "tmux send-keys -t top ' "
          (buffer-substring start end)
          " ' ; tmux send-keys -t top C-a ; tmux send-keys -t top '#'; tmux select-pane -t top; " ))
        (message the-command)
        (shell-command the-command)
    ))


This is beautiful! I had recently made something similar to this: https://github.com/orkohunter/keep


This is just perfect! So simple, so fast and can even sync to a Gist. Great job! I was looking for something like this for a long time.


Something similar, if you want to search most commonly used commands - https://github.com/tldr-pages/tldr


> [...] it is difficult to search them from shell history. There are many similar commands, but they are all different.

I think there's a much simpler way to go about this. Just add a snippet by typing it in your shell followed by an echo command, e.g.:

    ls -rt; echo "List all files reverse-sorted by date"
Then the problem remains to search your shell history, but there are many solutions for that already. And the good part is (besides not needing another tool) that you can search the same way for commands that were not labeled with a description.


There also exists something like stackoverflow-ish man-pages: `bro`. Basically, the same thing: community-maintained, upvotable bash snippets.


Nice work, going to give this a try soon. It'll be a big improvement over my mixture of aliases and bash history searches


Very cool, just need to add a centralized server feature, might have to fork this and try that.


If you feel like working on something like that, see my comment in this thread about Borg. We are pretty far ahead in the development, and happy to get contributors.

We have 4 members in the team but there are loads of work to do.


Good job on including these animated GIFs. I really, really wish every project would to that.


Cool project.

I have long held a ~/bin directory that contains things that are similar.


Perfect! It has solved the exact problem I run into. Thanks.





Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: