6 ms·
Show HN: Unix tool that visualizes shell commands usage
- przemub 6y agoA cool tool!
- breck 6y agoYES!!! I've been waiting for someone to do this for a decade or more. This + https://tldr.sh/ https://tldr.sh/ and the command line will be so much easier for me (but especially beginners!). With your tool, having an easy way to copy and paste your personal usage into some central website and then have some scripts would be a great thing to show aggregates. You could probably just create a single new repo and people could send PR's with their usage dumped to CSV (and they could remove any person info manually before). Then you just have a script that reads those CSVs and prints a nice web page with summary data.
- PeterWhittaker 6y agoLooks cool, but nothing much happens for me. I used brew to install go, then ran the following: % type -a go /usr/local/bin/go % cd tsukae % go get -d ./... go: downloading github.com/inconshreveable/mousetrap v1.0.0 % go run main.go o: downloading github.com/spf13/cobra v1.1.3 go: downloading github.com/gizak/termui/v3 v3.1.0 go: downloading github.com/mattn/go-runewidth v0.0.2 go: downloading github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d go: downloading github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 go: downloading github.com/spf13/pflag v1.0.5 ...a whole lot of usage information... ...but nothing useful (not a go person, so, YMMV).... Any ideas? FYI, % go version go version go1.16 darwin/amd64
- irevenko 6y agotry go 1.15
- howeyc 6y agocd tsukae go build ./tsukae
- PeterWhittaker 6y agoCloser! That got me the executable. Now I get a stack trace.... % ./tsukae bash panic: runtime error: slice bounds out of range [:7] with capacity 4 goroutine 1 [running]: github.com/irevenko/tsukae/cmd.GetShellCommandsUsage(0x1205b84, 0x4, 0x7, 0x4, 0x3, 0xc000066180, 0xc000127d78, 0x1159965, 0xc000120500) /Users/pww/tsukae/cmd/shell_name.go:22 +0x16d github.com/irevenko/tsukae/cmd.glob..func4(0x135df20, 0xc00005c8b0, 0x0, 0x1) /Users/pww/tsukae/cmd/commands.go:88 +0x1bf github.com/spf13/cobra.(*Command).execute(0x135df20, 0xc00005c8a0, 0x1, 0x1, 0x135df20, 0xc00005c8a0) /Users/pww/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:856 +0x2c2 github.com/spf13/cobra.(*Command).ExecuteC(0x135e1a0, 0xc000000180, 0xc000127f78, 0x10069e5) /Users/pww/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x375 github.com/spf13/cobra.(\*Command).Execute(...) /Users/pww/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897 main.main() /Users/pww/tsukae/main.go:12 +0x36
- irevenko 6y agoi figured it out, you just need to have bigger history, currently you only have 4 unique commands in your hist file.
- PeterWhittaker 6y agoMy history has a few thousand commands....
- pletnes 6y agoCool! I’ve used xonsh for some time, it can store history in sqlite format. Then any such analysis can be done with SELECT...ORDER BY etc.
- GrantZvolsky 6y agoIf one of your top commands is `clear`, you may like my alias `c`: $ alias c='clear &&' $ # Usage: $ c git status [1]: https://github.com/grantzvolsky/skel/blob/ea43b1969463a97f9623209ba0da705f9d084d5e/skels/xubuntu-2004/home/wx/.bashrc.d/aliases.sh#L4 https://github.com/grantzvolsky/skel/blob/ea43b1969463a97f96...
- bxparks 6y agoIf you use bash (or zsh, and maybe others), hit ^L (control-L) to clear the screen. From the bash(1) manual: clear-screen (C-l) Clear the screen leaving the current line at the top of the screen. With an argument, refresh the current line without clearing the screen.
- austinjp 6y agoI must hit ctrl-l a thousand times a day, learned it before I knew of clear.
- Aperocky 6y agoIf one of your top commands is `cd ../..` you may like my alias/function `..` $ .. 2 # go back 2 directories, i.e. 'cd ../..' $ .. # 'cd ..' https://github.com/Aperocky/unix-setup/blob/master/.bashrc#L49-L57 https://github.com/Aperocky/unix-setup/blob/master/.bashrc#L...
- caterama 6y agoPretty cool terminal visualizations, but tbh straight unix tools allow you to do this (might be different than 4th column for you depending on history format): `history | awk '{print $4}' | sort | uniq -c | sort` 56 tree 58 make 59 youtube-dl 69 cmake 71 which 76 docker 78 scala 80 drive 80 wget 96 curl 99 head 102 echo 105 pip 114 scp 119 ssh 131 open 135 conda 135 kubectl 141 man 181 sudo 298 mkdir 350 grep 378 ls 409 find 415 mv 544 cp 553 python 568 brew 601 cat 674 rm 1928 vim 1972 cd 2845 git Also, I'm noticing this won't catch anything in pipes otherwise I'd expect to see less and xargs pretty high up.
- atleta 6y agoAdd -n to the second sort to actually get a numerically (as opposed to lexically) sorted list. Also, here (using bash on linux) awk needs $2 instead of $4. It doesn't catch the pipes, because you are parsing the command lines as entered, and you filter for a single parameter from each.
- ReaLNero 6y agoInteresting command usage. One tip I'd offer is to use a `trash` command instead of `rm`. Unix doesn't usually offer it, but installing is as simple as `apt install trash-cli`. You've gotten lucky 674 times by not `rm`-ing the wrong thing.
- gfaure 6y agotsukae does mean "use" in Japanese -- but it's the blunt command form (命令形) "Use it!!"