Discussion

Sign in or Join to comment or subscribe

Alex R

Alex R

https://elrey.casa/me

2021-08-02T13:02:41Z ago

Haven’t finished listening yet, but got to the part where you were talking about your command history and I was curious about my commands. Since you were more curious about the actual individual commands themselves ( not the whole command that you typed, but the binary you launched ( sed, cat, vim, etc.. )). You can actually just run this command, which should work on either zsh or bash ( so not to leave adam out ( I actually oh-my-zsh as my default as well 🙃, but prefer bash for scripting ) ).

history | awk '{print $2}' | sort | uniq -c | sort -nr | head

The only real difference is the awk '{print $2}', which will print out the second “word” ( essentially not whitespace, but can be just numbers ) it identifies ( which the second “word” is the executable ).

By the way, you don’t need the -n 10 for the head command you read off during the podcast, because by default head returns the first 10 🙂

here are my results from the command above:

  1652 sudo
    981 ssh
    810 ls
    611 cd
    363 vim
    343 vagrant
    198 podman
    173 tmux
    163 docker
    162 rm

I didn’t realize how many things I sudo 😅 and as you can tell I am pretty much never staying on my laptop ( containers ( podman or docker ( which is just an alias to podman, but me copy pasting commands ) ), vagrant boxes, or ssh ) 😂. That also doesn’t count how many times I use the x2go ( pretty good YT video explaining it ) to essentially ssh over to another server, which I do every day 😅 ( you can learn more about my normal setup from here if you are interested ( essentially I x2go over to any other system from my lapt, which has the PCIe passthrough configured 2 monitors ) ).

also, instead of typing exit you can actually just hit Ctrl + d and it will exit your terminal instead of you having to type it 😁 you can learn some other keyboard shortcuts by watching this YT video that I created.

Jerod Santo

Jerod Santo

Bennington, Nebraska

Jerod co-hosts The Changelog, crashes JS Party & takes out the trash (his old code) once in awhile.

2021-08-02T13:14:56Z ago

Yeah, that command we used on the show was literally the first hit when searching something like ‘bash show top used commands’, so it got very little scrutiny (like, none) before we used it on the show.

I ran the command you provided above:

23676 git
7595 cd
5717 mix
2805 rspec
2591 mux
2540 exit
1931 gitx
1921 subl
1851 ls
1752 heroku

As you can see, I keep a looooong history of commands. I’ve known about ctrl + d for some time, but you should see how fast I can type exit after all these years 😆

jonasbn

jonasbn

Copenhagen, Denmark

Computer programmer, runner, LEGO builder, powernapper and father of 2 boys all squeezed in the few hours available.

2021-08-10T06:32:58Z ago

You should checkout HISTIGNORE environment variable, it can be used to slim down your history by eliminating trivial entries

export HISTIGNORE="pwd:ls:ls -l:cd:clear"

Perhaps exit could be added for Jerod.

REF:

Mohamed

Mohamed

Ruby Developer aka Joy Developer

2021-08-02T13:14:43Z ago

I’m going to try tldr. The first problem that I see with it is the name, it doesn’t stick to my head (non english speaker).

If you are going to say “use alias”, let me stop you there, because aliases doesn’t fix everything, because every couple of years I totally reset my computer, and install the software that I use, and if I don’t remember the name if this command, I will never install it.

Player art
  0:00 / 0:00