Live data from Hacker News

Show HN: Get help on any Linux command by typing 'howdoi –' in your terminal

github.com

31–40 of 59 posts

Re: Show HN: Get help on any Linux command by typing 'howdoi –' in your terminal

#31
post #22
post #21

Instead of this, I keep a permanent log of every shell command I ever typed and have a handy alias to keep through it. It also keeps track of the directory a command was run from, so I can limit my search. That way if I ever want to get back into a project I was working on long ago, I can just grep for commands run from that directory. Not only that, but I can use it to cd to directories quickly. So if I was working…

How do I get this?

Just put:

export PROMPT_COMMAND='if [ "$(id -u)" -ne 0 ]; then echo "$(date "+%Y-%m-%d.%H:%M:%S") $(pwd) $(history 1)" >> "${HOME}/bash_logs_$(hostname)/bash-history-$(date "+%Y-%m-%d").log"; fi'

in your ~/.bash_profile. You also may need to `mkdir "${HOME}/bash_logs_$(hostname)"`

I took this command from a Hacker News thread of the past. I don't have a link to it any more.

Re: Show HN: Get help on any Linux command by typing 'howdoi –' in your terminal

#32
post #23

I remember there was the `apropos` command for this use case but I don't think the results were good enough. It might be worth the comparison in your readme though. Anyway when I started using Linux I would have loved something like this.

I use `man -k` (which is the same thing) all the time.

It has a slightly different use case though.

Re: Show HN: Get help on any Linux command by typing 'howdoi –' in your terminal

#33
post #16

This would be good if.. you know.. `man` didn't exist.

Man is a terrible tool for quickly remembering how to do something I do once in a while. The examples—usually the most important part—are usually at the very bottom, if they’re even there.

I use man all the time for exactly this. In fact it is something man really excels at.

The other nice thing about looking up options in the man pages is that you often see other useful options that you didn't know existed. I've found some of my favourite options this way!

Re: Show HN: Get help on any Linux command by typing 'howdoi –' in your terminal

#34
post #12

bash-3.2$ howdoi "delete my root directory? Hypothetically speaking of course"

bash-3.2$ $(howdoi "delete my root directory? Hypothetically speaking of course")

Do it, do it! Though I think you need sudo in front of it :-)

Re: Show HN: Get help on any Linux command by typing 'howdoi –' in your terminal

#35
post #13

There's already a popular `howdoi` that me and a buddy made: https://github.com/gleitz/howdoi

Came here to comment on how good this one was, thinking this was what the post was about. 10/10 work on this project, never ceases to amaze me and my coworkers.

Re: Show HN: Get help on any Linux command by typing 'howdoi –' in your terminal

#37
post #22

Earlier quoted context omitted.

How do I get this?

Just put: export PROMPT_COMMAND='if [ "$(id -u)" -ne 0 ]; then echo "$(date "+%Y-%m-%d.%H:%M:%S") $(pwd) $(history 1)" >> "${HOME}/bash_logs_$(hostname)/bash-history-$(date "+%Y-%m-%d").log"; fi' in your ~/.bash_profile. You also may need to `mkdir "${HOME}/bash_logs_$(hostname)"` I took this command from a Hacker News thread of the past. I don't have a link to it any more.

There are several past posts with same bash one liner. For example https://news.ycombinator.com/item?id=14108671

Re: Show HN: Get help on any Linux command by typing 'howdoi –' in your terminal

#39
post #22
post #21

Instead of this, I keep a permanent log of every shell command I ever typed and have a handy alias to keep through it. It also keeps track of the directory a command was run from, so I can limit my search. That way if I ever want to get back into a project I was working on long ago, I can just grep for commands run from that directory. Not only that, but I can use it to cd to directories quickly. So if I was working…

How do I get this?

fish does this by default, and zoxide/z can switch to frecent directories.
Post reply on HN