Skip to content
This repository

`hist` command should support snippets #698

kyrylo opened this Issue · 4 comments

3 participants

Kyrylo Silin muescha John Mair
Kyrylo Silin

Recently, for the first time in my life, I used the hist command for the real purpose. And you know what? It sucked. My history is over 48000 entries and I wanted to replay the following: hist -r 48099..48104. Typing big numbers is no fun at all. Also, the code behind these numbers is nothing but a "foobar" class with some special behaviour. But it is very simple and I will undoubtedly need to use it later. The problem is that I relaunch Pry from time to time. In a fresh Pry session I have to press up-arrow key for like 10-20 times before I can find hist -r 48099..48104 command in history.

What if we add --save-snippet (-s) flag, which would save your favourite lines from history and give them a nice name?

No fun.

pry(main)> history --replay 48099..48101

Possible solution.

pry(main)> history --save-snippet 48099..48101 --name foobar-class
pry(main)> history --replay foobar-class


% pry
pry(main)> history --replay foobar-class
# ...

I guess you have a pertinent question: where to store foobar-class? I think we can store snippets in ~/.pry/history_snippets directory.

Example of history snippet file ~/.pry/history_snippets/foobar-class.

# That's all!
history --replay 48099..48101

In contrast to above-said

Maybe we should not touch hist command and add a new command for this kind of things (say, snip and its alias snippet). It would not rely on history.

I would gladly read other opinions (not only from Pry organization members). Would you use that?


I think its just an "alias" already implemente in terminal

Maybe we add a "hist --create-alias myname --replay 1234..1236"

Kyrylo Silin

Currently, the implementation is no object. I just showed that in order to explain things more graphically. I'm more interested in the topicality of this idea.

Deleted user

I like the general idea although I rarely use the hist command :P

John Mair

i think save-file is a more robust solution than this or perhaps there's room for an alternative solution via a plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.