Show HN: Unix tool that visualizes shell commands usage
github.com
github.com
`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.It doesn't catch the pipes, because you are parsing the command lines as entered, and you filter for a single parameter from each.
You've gotten lucky 674 times by not `rm`-ing the wrong thing.
% 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/amd64go build
./tsukae
% ./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 $ alias c='clear &&'
$ # Usage:
$ c git status
[1]: https://github.com/grantzvolsky/skel/blob/ea43b1969463a97f96... $ .. 2 # go back 2 directories, i.e. 'cd ../..'
$ .. # 'cd ..'
https://github.com/Aperocky/unix-setup/blob/master/.bashrc#L... alias ~='pushd ~'
(Those are tildes but may look like dashes depending on your font and size...)Not as fancy as some other aliases I see here but does the (basic) trick.
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.
This + 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.