🧑‍💻📊 Show off your most used shell commands

Related tags

Command Line tsukae
Overview

tsukae 🧑‍💻 📊

Tsukae, 使え - means use in Japanese (so it refers to commands that you use)

Built on top of termui and cobra


Big shoutout to jokerj40 for suggesting this project idea (the original thought was to parse the history file)

Usage 🔬

- zsh or bash

Flags 🎌

-p, --piechart - use with (draws only piechart widget)
-b, --barchart - use with (draws only barchart widget)
-l, --list - use with (draws only list widget)

Draw all widgets

tsukae

Draw specific widget

tsukae -p

tsukae -b

tsukae -l

Pass certain commands number (1-15) and draw all widgets

tsukae 10

Draw specific widget with certain commands number

tsukae 10 -p
tsukae 5 -b
tsukae 3 -l

Contributing 🤝

Contributions, issues and feature requests are welcome! 👍
Feel free to check open issues.

Quick Start 🚀

git clone https://github.com/irevenko/tsukae.git
cd tsukae
go get -d ./...
go run main.go

What I Learned 🧠

  • Parsing Text Files using Go
  • Drawing termui

ToDo

  • auto detect shell, manual shell path
  • maybe fish, sh, etc... support
  • make proper PieChart render
  • binaries for osx, linux
  • customize TUI (colors, new charts and ways to visualize commands usage)

License 📑

(c) 2021 Ilya Revenko. MIT License

Comments
  • Problem with zsh

    Problem with zsh

    This line was creating problem for me.
    Error message: panic: runtime error: index out of range [1] with length 1

    changing
    historySlice[i] = commandSlice[1] //writing command name after sudo
    to
    historySlice[i] = commandSlice[0] //writing command name after sudo
    solved problem for me.

    I don't have any programming language knowledge but i guess it's because of previous for loop, that remove timestamps.

    opened by TaylanTatli 15
  • Doesn't work on macOS

    Doesn't work on macOS

    Not sure what the issue is, $HOME and $HISTFILE are all set correctly. The file is accessible and readable.

    $ echo $HOME
    /Users/heapcrash
    
    $ echo $HISTFILE
    /Users/heapcrash/.zhistory
    
    $ tail -2 $HISTFILE
    : 1614405148:0;echo $HISTFILE
    : 1614405182:0;tail -2 $HISTFILE
    
    $ go run main.go zsh
    2021/02/27 00:52:12 Can't find or open /.zsh_history in: /Users/heapcrash
    exit status 1
    
    opened by heapcrash 8
  • Unable to parse history files with at timestamp written to them (HISTTIMEFORMAT set)

    Unable to parse history files with at timestamp written to them (HISTTIMEFORMAT set)

    bash or zsh history files that have timestamps written into them cannot be parsed.

    2021/03/03 14:19:20 <COMMANDS_NUMBER> must be an Integer
    exit status 1
    
    
    opened by kebeda 6
  • Feature: Working directories instead of shell history (via z and zsh-z)

    Feature: Working directories instead of shell history (via z and zsh-z)

    There are two command-line tools, z and zsh-z, which keep track of your most-used and recently-used command-line DIRECTORIES (they say "frecency" for a mixture of frequently and recently) as opposed to tsukae's current display of just the commands.

    z: https://github.com/rupa/z zsh-z:https://github.com/agkozak/zsh-z

    The way you use the tool is to source a script that sets a hook that runs every time your prompt is displayed. You can then enter z foo where foo is a substring that is compared against your most 'frecently' used directories.

    Unfortunately, z is a shell function, not a callable program. However, its data is stored in ~/.z, and looks like the details below. Note the path, its score, and the timestamp of access are all shown. This should be easy for tsukae to parse out, and offer a mode in addition to bash and zsh called z. You'd want to show the highest-scored N entries in tsukae.

    Click to expand
    $ head ~/.z
    /Users/zachriggle/gdb-build|2.95589|1614576609
    /Applications/IDA Pro 7.5|1.21395|1612766077
    /Users/zachriggle/ctf-solutions|25.2152|1614161190
    /Users/zachriggle/autoprogram|13.8645|1614141904
    /Users/zachriggle/pwntools/.git|3.31034|1614112324
    /Users/zachriggle/ctf-solutions/defcon/2020/finals/gameboooy|2.3126|1596929922
    /Users/zachriggle/ctf-solutions/defcon|1.93996|1614161192
    /usr/local/Cellar|2.40773|1613560248
    /Users/zachriggle/sphinx|5.51275|1613553642
    /Users/zachriggle/usercorn|2.23848|1612281791
    

    Disclaimer: I would implement this myself, but I am barred from FOSS contributions by my employer.

    opened by zachriggle 4
  • Documentation notes

    Documentation notes

    Cool project! Thanks for sharing. I have some ideas to improve the readme - I hope these are helpful.

    1. I haven't used go, so it wasn't obvious to use go build. Might want to replace the suggested go run main.go with go build in the description (also assumes go is installed).
    2. The blacklist file wasn't automatically created for me. I just used mkdir ~/.config/tsukae and then touch blacklist.

    Thanks!

    opened by brentstewart 3
  • Feature: Configurable command blacklist

    Feature: Configurable command blacklist

    Tsukae is great and does right what it says on the tin. However, I don't necessarily care about my usage of e.g. cd or echo.

    It would be nice if Tsukae had a configurable blacklist of commands to NOT show. Maybe have a list of commands to ignore in e.g. ~/.config/tsukae/blacklist.

    opened by zachriggle 2
  • Feature: Configurable colors, and 256-color or maybe even 24-bit color (to support colorblind-friendly palette)

    Feature: Configurable colors, and 256-color or maybe even 24-bit color (to support colorblind-friendly palette)

    Configurable Color Palette

    I am red-green colorblind, so it makes it very hard to distinguish between some of the sections in the pie chart mode. So first, it would be nice to be able to configure which colors are used (ANSI "green" and "yellow" are indistinguishable to me). There are a few colors that aren't used (and even then there's the bold variants and background-color variants).

    For example, here I cannot tell the difference between the gc and verify-fix slices in this picture:

    Screen Shot 2021-03-04 at 1 17 23 PM

    It would be nice to be able to specify the set of colors used by tsukae.

    Stretch Goals

    It would be even better if tsukae were to support 256 colors, or even 24-bit color, since most terminals support this now. It seems there is even a Go package to provide this support, with https://github.com/gdamore/tcell.

    You can check if your terminal supports 24-bit color with the following command:

    awk 'BEGIN{
        s="/\\/\\/\\/\\/\\"; s=s s s s s s s s;
        for (colnum = 0; colnum<77; colnum++) {
            r = 255-(colnum*255/76);
            g = (colnum*510/76);
            b = (colnum*255/76);
            if (g>255) g = 510-g;
            printf "\033[48;2;%d;%d;%dm", r,g,b;
            printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
            printf "%s\033[0m", substr(s,colnum+1,1);
        }
        printf "\n";
    }'
    
    opened by zachriggle 2
  • Feature: Variable number of commands shown

    Feature: Variable number of commands shown

    Currently, it seems that only a handful of commands are shown. It would be useful to be able to set a variable number of commands, which are less useful for pie charts, but more useful for the list format.

    opened by zachriggle 2
  • Xonsh support

    Xonsh support

    Hi!

    It will be great to have xonsh shell support.

    The history backend in xonsh is customisable but it has two default backends to choose: json and sqlite.

    How to create and get the data for two backends:

    pip install xonsh  # or install/docker ways: https://xon.sh/contents.html#installation
    
    # Json
    echo \$XONSH_HISTORY_BACKEND = \'json\' > /tmp/rc_json
    xonsh --rc /tmp/rc_json
    echo 1
    echo 2
    exit
    cd ~/.local/share/xonsh/
    cat xonsh-*.json | jq .data.cmds[].inp
    # "echo 1\n"
    # "echo 2\n"
    
    # SQLite
    echo \$XONSH_HISTORY_BACKEND = \'sqlite\' > /tmp/rc_sqlite
    xonsh --rc /tmp/rc_sqlite
    echo 1
    echo 2
    exit
    pip install sqlite_web
    sqlite_web ~/.local/share/xonsh/xonsh-history.sqlite
    # http://127.0.0.1:8080/xonsh_history/query/
    # SELECT * FROM "xonsh_history"
    
    

    Thanks!

    For community

    ⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment

    opened by anki-code 2
  • Feature request: would like tsukae to ignore specified commands

    Feature request: would like tsukae to ignore specified commands

    I would like to be able to pass certain commands to be ignored when displaying the charts, i.e. the number of times I invoke git or ls or cd is not as important to me as other commands, but these are typically at the top of the charts, crowding them out. Maybe a command line option that takes one or more commands (or repeat the option) to be eliminated from the final list?

    opened by kebeda 1
  • Feature: Commands most used in <time period>

    Feature: Commands most used in

    Currently, tsukae lists commands from the entire history file.

    It would be useful to see which commands were most used in the last (day, week, month).

    This won't work for bash, but zsh puts timestamps in its history file.

    opened by zachriggle 1
Owner
Ilya Revenko
🦠 life is work ⚙️
Ilya Revenko
This utility verifies all commands used by a shell script against an allow list

Find external commands required by shell scripts When writing shell scripts that need to run portably across multiple hosts and platforms, it's useful

Alec Thomas 11 Aug 15, 2022
Create new commands from your shell history or terminal.

overdub Create new commands from your shell history or terminal. TODO list for initial release Filter out unlikely commands (e.g. package managers) fr

Michael Zalimeni 6 Aug 9, 2022
ap 是一个 shell 工具,可以让其它 shell 命令的输出能够自动进入交互翻页模式

ap -- auto-pager ap 是一个 shell 工具,可以让其它 shell 命令的输出能够自动进入交互翻页模式。 ap 由两部分组成,一个 Go 语言编写的二进制程序,负责捕获命令的输出并支持翻页, 和一组 shell 脚本,负责为用户指定的命令清单创建与之同名的 wrapper。 经

flw 12 Apr 12, 2022
Tool for shell commands execution, visualization and alerting. Configured with a simple YAML file.

Sampler. Visualization for any shell command. Sampler is a tool for shell commands execution, visualization and alerting. Configured with a simple YAM

Alexander Lukyanchikov 11k Nov 22, 2022
Go package for running Linux distributed shell commands via SSH.

Go package for running Linux distributed shell commands via SSH.

Disco 146 Nov 9, 2022
Testing local and remote shell commands in Go

Testing local and remote shell commands in Go. This is an (intentionally simplified) example of how unix shell commands can be unit-tested in Go. The

Anton 5 Nov 30, 2021
null 0 Jan 27, 2022
Command line tool to show the weather information of your city

go-weather when you type weather <city>, it will show you the weather of the city you input. Useful API comes from openweathermap.org. You can registe

常乐村喵蕉君 0 Nov 5, 2021
Show Languages In Code. A fast and lightweight CLI to generate stats on the languages inside your project

slic Show Languages In Code. Usage Run it with an -h flag to list all commands. -d flag can be used to specify the directory of search -i flag can be

Saurav Pal 3 Dec 25, 2021
Tool to extract log files off of the roboRIO automatically

extractor Tool to extract log files off of the roboRIO automatically Steps This program does the following steps once ran: Read from TOML config file

Team 501 - The PowerKnights 2 May 15, 2022
Run your MapReduce workloads as a single binary on a single machine with multiple CPUs and high memory. Pricing of a lot of small machines vs heavy machines is the same on most cloud providers.

gomap Run your MapReduce workloads as a single binary on a single machine with multiple CPUs and high memory. Pricing of a lot of small machines vs he

null 21 Sep 16, 2022
A zoom meeting scanner made in go and it will show the meeting information

zoom-scanner A zoom meeting scanner made in go and it will show the meeting information Installation: git clone https://github.com/krishpranav/zoom-sc

Krisna Pranav 7 Aug 31, 2022
rj is a command line tool show the HTTP Response as JSON

rj rj is a command line tool show the HTTP Response as JSON Installation

Yusuke Wada 43 Aug 24, 2022
A goroutine monitor to keep track of active routines from within your favorite shell.

roumon A goroutine monitor to keep track of active routines from within your favorite shell. Features Track live state of all active goroutines Termin

Armin Becher 125 Nov 21, 2022
Tools for the Gio project, most notably gogio for packaging Gio programs

Gio Tools Tools for the Gio project, most notably gogio for packaging Gio programs. Issues File bugs and TODOs through the issue tracker or send an em

Gio 4 Oct 5, 2022
Are you programming and suddenly your stomach is rumbling? No problem, order your Ifood without leaving your favorite text editor ❤️

vim-ifood Você ta programando e de repente bateu aquela fome? Sem problemas, peça seu Ifood sem sair do seu editor de texto favorito ❤️ Are you progra

Felipe Volpone 4 Jun 2, 2022
🎀 a nice lil shell for lua people made with go and lua

Hilbish ?? a nice lil shell for lua people made with go and lua It is currently in a mostly beta state but is very much usable (I'm using it right now

Hilbis Development 294 Nov 18, 2022
Shelby is a fast ⚡️ , lightweight ☁️ , minimal✨, shell prompt written in Go.

Shelby is a fast ⚡️ ,lightweight ☁️ ,minimal ✨ , shell prompt written in Pure Go. Installation Follow the steps below(Linux and macOS), and Post Insta

Athul Cyriac Ajay 167 Oct 21, 2022
A multiple reverse shell sessions/clients manager via terminal written in go

A multiple reverse shell sessions/clients manager via terminal written in go

Krisna Pranav 11 Nov 9, 2022