Giter Club home page Giter Club logo

muc's Introduction

Hi there 👋

Make yourself at home.

muc's People

Contributors

9glenda avatar anemovva avatar arkaeriit avatar ehllie avatar frectonz avatar nate-sys avatar nullishamy avatar xezo360hye avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

muc's Issues

`thread 'main' panicked at 'HISTFILE not set: NotPresent', src/main.rs:13:42`

Runs when trying to run muc, with and without arguments.

Installed through cargo install --git=https://github.com/nate-sys/muc as instructed in the Readme. rustc version is 1.68.0.

Short backtrace:

thread 'main' panicked at 'HISTFILE not set: NotPresent', src/main.rs:13:42
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/panicking.rs:64:14
   2: core::result::unwrap_failed
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/result.rs:1790:5
   3: muc::main

Add flake.nix

You can provide a flake.nix inside your project to accommodate people using nix

Cargo compile fails: error[E0658]: `let...else` statements are unstable

When I try to compile the project with cargo build --release, the compile fails with the following error:
error[E0658]: let...else statements are unstable.

The full error is:
error[E0658]: let...else statements are unstable
--> src/hist_file.rs:16:5
|
16 | let Ok(histfile_buffer) = std::fs::File::open(&args.file) else { panic!("Please specify a valid histfile")};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #87335 rust-lang/rust#87335 for more information
= help: add #![feature(let_else)] to the crate attributes to enable

For more information about this error, try rustc --explain E0658.
error: could not compile muc due to previous error /0.3s

I am using rustup version 1.25.1-2.

Config file

Muc uses clap for customization. This is good but having a config file can make things better:

  • The command will be shorter overall
  • Solves the issue of commands not being counted when their written with "sudo" or "doas". With a config file, the user can simply specify leader commands.
  • Same thing with aliases. Just specify them in your config file.

Unreliable parsing of ZSH history

I'm seeing multiple issues when using muc with a standard ZSH / oh-my-zsh history file:

  • The top command is shown as 0...
    image

  • ...and command timestamps are listed as individual commands:
    image

    Relevant lines:

    : 1662623233:0;some command
    : 1662623254:0;another command
    
  • URLs get included as commands but with the https: cut off:
    image

    Relevant lines:

    : 1670425618:0;curl -fsSL https://raw.githubusercontent.com/spicetify/spicetify-cli/master/install.sh | sh\
    curl -fsSL https://raw.githubusercontent.com/spicetify/spicetify-marketplace/main/resources/install.sh | sh
    

Installed version: d4bb4c6 (0.1.0)

zsh_history issues

Running on zsh_history (OhMyZSH) results in this error

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/hist_file.rs:89:32
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This can be fixed by replacing:

muc/src/hist_file.rs

Lines 87 to 89 in d8336bc

let words = line.split_whitespace().collect::<Vec<&str>>();
let (first, second) = (words.first().unwrap().to_string(), words.get(1));

with:

        let words = line.split_whitespace().collect::<Vec<&str>>();
        if words.first().is_none() {
            continue;
        }

        let (first, second) = (words.first().unwrap().to_string(), words.get(1));

the last value of words is None, unwrapping it causes an error.

after the fix there is another issue:

 [▮▮▮▮▮▮▮▮▮▮] 54.01%  9826 :  -- No idea what this is supposed to mean.
[▮         ]  7.51%  1367 ls 
[▮         ]  6.97%  1268 cd 
[          ]  4.82%   877 vi 
[          ]  2.35%   428 yay 
[          ]  2.19%   399 sudo -e, rm, mount ... -- intentional?
[          ]  1.74%   317 rm 
[          ]  1.72%   313 killall 
[          ]  1.43%   261 cargo 
[          ]  1.34%   243 curl 
...2894 (15.91%) others

Ignore `sudo` / `doas`

I am not sure if this is why --prefix exists but I could not make it work myself. There are many commands I start with sudo and Muc only shows sudo at the top. IMHO it should look into the actual command somehow (at least just use the next word), maybe make a flag to toggle (or if possible instructions on how to achieve this with --prefix or whatever other flags)

Add note about insufficent backwards compatibility

When using cargo install (or compiling through AUR) I got the following error

error[E0658]: `let...else` statements are unstable
  --> src/hist_file.rs:17:5
   |
17 |     let Ok(histfile_buffer) = std::fs::File::open(&args.file) else { panic!("Please specify a valid histfile")};
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #87335 <https://github.com/rust-lang/rust/issues/87335> for more information

For more information about this error, try `rustc --explain E0658`.
error: could not compile `muc` due to previous error
error: failed to compile `muc v0.1.0 (https://github.com/nate-sys/muc#cf4fdec2)`

All I did to fix it was to upgrade rust to the latest version. Though this is not blatantly obvious. I therefore think you should add a note about troubleshooting or minimum requirements to run the application.

License

Right now there is no license provided, consider adding one (I recommend GNU GPL v3 of course, but you might want to choose MIT/BSD/etc.)

Crashes on macOS

Hey! Just saw your project and thought it was awesome.

I am using macOS 12.6.2 and rust version 1.66.0 (stable branch)

When I tried running muc --file "/Users/tal/.zsh_history" --count 10 --pretty it gave me this error:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: InvalidData, message: "stream did not contain valid UTF-8" }', src/hist_file.rs:7:51
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

And when I run it with RUST_BACKTRACE=1 I get this:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: InvalidData, message: "stream did not contain valid UTF-8" }', src/hist_file.rs:7:51
stack backtrace:
   0: rust_begin_unwind
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/panicking.rs:65:14
   2: core::result::unwrap_failed
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/result.rs:1791:5
   3: muc::hist_file::get_contents
   4: muc::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

And with RUST_BACKTRACE=full:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: InvalidData, message: "stream did not contain valid UTF-8" }', src/hist_file.rs:7:51
stack backtrace:
   0:        0x100fe4784 - std::backtrace_rs::backtrace::libunwind::trace::hbe97f4303076f99a
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:        0x100fe4784 - std::backtrace_rs::backtrace::trace_unsynchronized::hb462a91ac605b16b
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x100fe4784 - std::sys_common::backtrace::_print_fmt::h555c176cf2344151
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:65:5
   3:        0x100fe4784 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he84d5e26d26c914d
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:44:22
   4:        0x100ff82f4 - core::fmt::write::h07c7e4739f78f3b0
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/fmt/mod.rs:1209:17
   5:        0x100fe264c - std::io::Write::write_fmt::h4a3c5f094ffc65e8
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/io/mod.rs:1682:15
   6:        0x100fe4598 - std::sys_common::backtrace::_print::h03a1c9ac6001091a
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:47:5
   7:        0x100fe4598 - std::sys_common::backtrace::print::h6fc2cc8be2392a8e
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:34:9
   8:        0x100fe5b4c - std::panicking::default_hook::{{closure}}::h3bb44ba6ff437e23
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:267:22
   9:        0x100fe58a4 - std::panicking::default_hook::h92c6668a1a98ae8c
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:286:9
  10:        0x100fe6188 - std::panicking::rust_panic_with_hook::h9b8acc949e1fb807
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:688:13
  11:        0x100fe5f98 - std::panicking::begin_panic_handler::{{closure}}::hfc38b2cc56e3623c
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:579:13
  12:        0x100fe4bec - std::sys_common::backtrace::__rust_end_short_backtrace::hbafd151207fc448f
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:137:18
  13:        0x100fe5cec - rust_begin_unwind
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:575:5
  14:        0x10100074c - core::panicking::panic_fmt::h8c7f3d540a75578f
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/panicking.rs:65:14
  15:        0x1010008a4 - core::result::unwrap_failed::h666d2c7e0d130ea0
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/result.rs:1791:5
  16:        0x100f8df68 - muc::hist_file::get_contents::h91389b0630c99091
  17:        0x100f88300 - muc::main::h2013a148f8a28f91
  18:        0x100f8d220 - std::sys_common::backtrace::__rust_begin_short_backtrace::h10cf803f9cdcd9b0
  19:        0x100f820b0 - std::rt::lang_start::{{closure}}::h1ebcf9eb3fffb888
  20:        0x100fdf088 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::ha4b10a239e2af884
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/ops/function.rs:286:13
  21:        0x100fdf088 - std::panicking::try::do_call::h6b4bcb7d3635e86a
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:483:40
  22:        0x100fdf088 - std::panicking::try::h579c8cca81ff0f69
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:447:19
  23:        0x100fdf088 - std::panic::catch_unwind::h4a997c12755a6e33
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panic.rs:137:14
  24:        0x100fdf088 - std::rt::lang_start_internal::{{closure}}::hf20057b44f57f87c
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/rt.rs:148:48
  25:        0x100fdf088 - std::panicking::try::do_call::hdfca34da16d8863f
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:483:40
  26:        0x100fdf088 - std::panicking::try::h4f4022e500de0807
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:447:19
  27:        0x100fdf088 - std::panic::catch_unwind::h62721286166676e8
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panic.rs:137:14
  28:        0x100fdf088 - std::rt::lang_start_internal::h659a783147314d97
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/rt.rs:148:20
  29:        0x100f8ada0 - _main

any idea why this is? Thanks for making this, by the way.

Piped commands

I know this is a work in progress. I saw your roadmap but didn't notice this there.

Piped commands should also be parsed.
For example:

cat /file/list | grep string
here cat as well as grep should be counted

Also, this

cat /file/something | grep string | awk '{print $2}'

Here cat, grep, and awk all should be counted.

Just wanted to be sure that you were aware of this.

Handle non UTF8 encoding / better error message

Hi there 👋

Nice tool! I noticed that my ZSH history file was latin1 encoded for some reason, so the program crashed on read_to_string:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: InvalidData, message: "stream did not contain valid UTF-8" }', src/hist_file.rs:7:51

After opening the file with vim and doing a quick :set fenc=utf8 it worked flawlessly.
I don't know how common latin1 encoded histories are, so it's probably just fine to not use unwrap() here for a better error message.

shell flag not working with fish

The shell args with fish as its value does not help parse a fish history. I could try to fix it later today or tomorrow.

^[n.n]^ ~/Dev/rust/muc >HISTFILE=~/.local/share/fish/fish_history target/debug/muc --file $HIST
FILE --count 10 --prefix="- cmd: " --pretty
[▮▮▮▮▮▮▮▮▮▮]  8.13% 188 cd 
[▮▮▮▮▮▮▮▮  ]  6.75% 156 vim 
[▮▮▮▮▮▮▮   ]  5.75% 133 git 
[▮▮▮▮▮▮    ]  5.58% 129 ls 
[▮▮▮▮▮▮    ]  5.23% 121 sudo 
[▮▮▮▮▮     ]  4.54% 105 mv 
[▮▮▮▮      ]  4.02%  93 aria2c 
[▮▮▮       ]  3.03%  70 cat 
[▮▮▮       ]  2.98%  69 rm 
[▮▮        ]  1.82%  42 mkdir 
 ...  1206 (~52%) others 
^[n.n]^ ~/Dev/rust/muc >HISTFILE=~/.local/share/fish/fish_history target/debug/muc --file $HIST
FILE --count 10 --shell fish --pretty
[▮▮▮▮▮▮▮▮▮▮] 24.00% 2392 when 
[▮▮▮▮▮     ] 13.16% 1311 - 
[▮▮▮▮      ] 11.46% 1142 paths 
[          ]  2.26%  225 cd 
[          ]  1.90%  189 vim 
[          ]  1.63%  162 ls 
[          ]  1.54%  153 git 
[          ]  1.44%  143 sudo 
[          ]  1.24%  124 mv 
[          ]  0.93%   93 aria2c 
 ...  4031 (~40%) others 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.