cantino / mcfly

Fly through your shell history. Great Scott!
MIT License
6.75k stars 176 forks source link

Feature: quick stats 📊 #420

Open nicokosi opened 1 month ago

nicokosi commented 1 month ago

See https://github.com/cantino/mcfly/issues/330.

I propose this basic implementation. :blush: I introduced a few unit tests. Integration tests may be more useful.

See the commit message for an example of output.

Note that the number of "first commands, sorted by occurrences" is hard-coded to 10. Should it be configurable from the command line?

nicokosi commented 3 weeks ago

I think that this message is wrong (10 is the limit):

 - has 10 distinct commands.

Converting the PR to draft again... :innocent:

nicokosi commented 3 weeks ago

I think that this message is wrong (10 is the limit):

 - has 10 distinct commands.

Converting the PR to draft again... 😇

Fixed in commit 7878c2aeec027a04fe84e73560bf0dd4ff6e7d73.

nicokosi commented 3 weeks ago

I have added a fixupcommit c75b41ab6b2e49d3170f7db369705e0360084702 in order to fix Clippy warnings from the first commit 😇 (sorry, I did not run Clippy).

Badly, tests fail on CI. 😭

Screenshot 2024-06-05 at 05 54 10

test stats_generator::tests::empty_history ... FAILED test stats_generator::tests::full_history ... FAILED test stats_generator::tests::partial_history ... FAILED

failures:

---- stats_generator::tests::empty_history stdout ---- McFly: Importing shell history for the first time. This may take a minute or two...thread 'stats_generator::tests::empty_history' panicked at src/shell_history.rs:62:17: McFly error: Please ensure HISTFILE or MCFLY_HISTFILE is set for your shell (environment variable not found)

nicokosi commented 3 weeks ago

I have added a fixupcommit c75b41a in order to fix Clippy warnings from the first commit 😇 (sorry, I forgot to run Clippy).

Badly, tests fail on CI. 😭 Screenshot 2024-06-05 at 05 54 10

test stats_generator::tests::empty_history ... FAILED test stats_generator::tests::full_history ... FAILED test stats_generator::tests::partial_history ... FAILED failures: ---- stats_generator::tests::empty_history stdout ---- McFly: Importing shell history for the first time. This may take a minute or two...thread 'stats_generator::tests::empty_history' panicked at src/shell_history.rs:62:17: McFly error: Please ensure HISTFILE or MCFLY_HISTFILE is set for your shell (environment variable not found)

I tried to fix tests in commit c0fbb640e8e08894edfe62974db96cb0a941fb2e (they "work on my machine" :registered:) 🤞

cantino commented 3 weeks ago

Thank you for working on this @nicokosi, it's an interesting feature. Here is the output for me:

📊 Quick stats:
  - history has 66846 items ;
  - 10 first commands, sorted by occurrences:
    git (29994)
    cd (3102)
    vi (2685)
    less (2512)
    j (1316)
    ./bin/dev-docker (1171)
    rm (1068)
    yarn (882)
    cargo (859)

I wonder if it would be more useful if it ignored very short commands by default, or if it did a breakdown by directory of execution or something?

nicokosi commented 3 weeks ago

It seems good ideas. I think I will try something with them in the next days.

nicokosi commented 2 weeks ago

Thank you for working on this @nicokosi, it's an interesting feature. Here is the output for me:

📊 Quick stats:
  - history has 66846 items ;
  - 10 first commands, sorted by occurrences:
    git (29994)
    cd (3102)
    vi (2685)
    less (2512)
    j (1316)
    ./bin/dev-docker (1171)
    rm (1068)
    yarn (882)
    cargo (859)

I wonder if it would be more useful if it ignored very short commands by default, or if it did a breakdown by directory of execution or something?

I propose 173a935b1ee865ef9c6be95d06fef99b6e74db1a and 1911b2081ba7ef7869b2a9e11b0edb2b46733725. I think I will also add a parameter for the number of "first commands, sorted by occurrences" (which is hard-coded to 10).

nicokosi commented 2 weeks ago

Thank you for working on this @nicokosi, it's an interesting feature. Here is the output for me:

📊 Quick stats:
  - history has 66846 items ;
  - 10 first commands, sorted by occurrences:
    git (29994)
    cd (3102)
    vi (2685)
    less (2512)
    j (1316)
    ./bin/dev-docker (1171)
    rm (1068)
    yarn (882)
    cargo (859)

I wonder if it would be more useful if it ignored very short commands by default, or if it did a breakdown by directory of execution or something?

I propose 173a935 and 1911b20. I think I will also add a parameter for the number of "first commands, sorted by occurrences" (which is hard-coded to 10).

Done in commit a87c425385993a4dc8aba3a1d98eea1349e17719.

nicokosi commented 2 weeks ago

Thank you for working on this @nicokosi, it's an interesting feature. Here is the output for me:

📊 Quick stats:
  - history has 66846 items ;
  - 10 first commands, sorted by occurrences:
    git (29994)
    cd (3102)
    vi (2685)
    less (2512)
    j (1316)
    ./bin/dev-docker (1171)
    rm (1068)
    yarn (882)
    cargo (859)

I wonder if it would be more useful if it ignored very short commands by default, or if it did a breakdown by directory of execution or something?

I propose 173a935 and 1911b20. I think I will also add a parameter for the number of "first commands, sorted by occurrences" (which is hard-coded to 10).

Done in commit a87c425385993a4dc8aba3a1d98eea1349e17719.

nicokosi commented 2 weeks ago

Thank you for working on this @nicokosi, it's an interesting feature. Here is the output for me:

📊 Quick stats:
  - history has 66846 items ;
  - 10 first commands, sorted by occurrences:
    git (29994)
    cd (3102)
    vi (2685)
    less (2512)
    j (1316)
    ./bin/dev-docker (1171)
    rm (1068)
    yarn (882)
    cargo (859)

I wonder if it would be more useful if it ignored very short commands by default, or if it did a breakdown by directory of execution or something?

I propose 173a935 and 1911b20. I think I will also add a parameter for the number of "first commands, sorted by occurrences" (which is hard-coded to 10).

I think it's done in commit a87c425385993a4dc8aba3a1d98eea1349e17719.

I will be on holidays for about 10 days. Feel free to update this PR... or I will have a look when I will be back! :palm_tree: