Coder Social home page Coder Social logo

ginh's People

Contributors

codacy-badger avatar crclark96 avatar devyboy avatar theryangeary 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  avatar  avatar

ginh's Issues

does not work on zsh

11:01:02 [carbolymer:/tmp]↥ % ./ginh.sh      
entries=15, file=/home/carbolymer/.zhistory, char==, len=168
grep: /home/carbolymer/.zhistory: No such file or directory
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 =====================================================================================================================================================================  1
 =  
 =  
 =  
 =  
 =  
 =  
 =  
 =  
 =  
 =  
 =  
 =  
 =  
 =  
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
11:01:07 [carbolymer:/tmp]↥ % stat /home/carbolymer/.zhistory
  File: /home/carbolymer/.zhistory
  Size: 447249    	Blocks: 880        IO Block: 4096   regular file
Device: 804h/2052d	Inode: 528724      Links: 1
Access: (0600/-rw-------)  Uid: ( 1000/carbolymer)   Gid: ( 1000/carbolymer)
Access: 2019-01-28 11:00:26.039894271 +0100
Modify: 2019-01-28 10:50:32.299924404 +0100
Change: 2019-01-28 10:50:32.299924404 +0100
 Birth: -

process being pushed to background on zsh

 ./ginh.sh
[2]  + 27930 suspended (tty input)  ./ginh.sh

./ginh.sh -h   
[3]  + 12944 suspended (tty input)  ./ginh.sh -h

instead, It works as expected on bash

bash                                                                                                                                                                                
 ./ginh.sh 
entries=15, file=/home/x/.bash_history, char==, len=209
...

it gets me output when I run fg

[BUG] sudo still appears in graph

On the most recent commit (after switching alias reversing and sudo filter), sudo still appears as an entry in my top commands

ginh on  master [$] 
➜ ./ginh.sh 
entries=15, file=/home/crclark/.zsh_history, char==, len=86
---------------------------------------------------------------------------------------
 git ============================================================================  1926
  cd ================================================  1231
  ls =============================================  1145
make =================================  844
java ===========================  679
 cat =======================  575
 vim ====================  498
sudo =================  412
open ==============  341
  mv ========  192
  rm =======  178
  fg =====  128
 dot ====  97
  cp ====  93
 man ====  89
---------------------------------------------------------------------------------------

histfile.txt

Not working with ZSH History

Great Script! It doesn't work with ZSH History files though, as they are formated differently. The following should work:
calc=$(cat $histfile | sed s/sudo//g | awk -F ';' '{print $2}' | awk '{print $1}' | sort | uniq -c | sort -rn)
I also included a sed command to strip sudo out, as all sudo commands are counted the same. But that's just, because i'm more interested in what i actually did with sudo. One could output two graphs, one for Sudo commands and one without.

Maybe the current shell can be recieved programatically with "echo $0" and handle the histfile and calculation depending on what's returned.

[BUG] debug commit is dependent on git repo

Describe the bug
Using the -d flag to get the debug output prints the commit hash of the HEAD of the repo. If ginh is run from inside this repo that's fine, however, if it is installed and run, it gives

fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
commit: 

And if it is installed and run from inside another git repo, it will give a hash from that repo, which is useless.

Debug
See above

[REQUEST] add more info to help flag

grep --help as an example, provides each flag with a short description of its features

ginh on  patch-28 took 2s 
➜ grep --help
Usage: grep [OPTION]... PATTERN [FILE]...
Search for PATTERN in each FILE.
Example: grep -i 'hello world' menu.h main.c

Pattern selection and interpretation:
  -E, --extended-regexp     PATTERN is an extended regular expression
  -F, --fixed-strings       PATTERN is a set of newline-separated strings
  -G, --basic-regexp        PATTERN is a basic regular expression (default)
  -P, --perl-regexp         PATTERN is a Perl regular expression
  -e, --regexp=PATTERN      use PATTERN for matching
  -f, --file=FILE           obtain PATTERN from FILE
  -i, --ignore-case         ignore case distinctions
  -w, --word-regexp         force PATTERN to match only whole words
  -x, --line-regexp         force PATTERN to match only whole lines
  -z, --null-data           a data line ends in 0 byte, not newline

Division by zero

> ./ginh.sh -f /Users/sortega/.zsh_history
entries=15, file=/Users/sortega/.zsh_history, char==, len=110
sort: Illegal byte sequence
./ginh.sh: line 101: freq[n]=counts[n] *     107     / counts[0] : division by 0 (error token is " ")
./ginh.sh: line 101: freq[n]=counts[n] *     107     / counts[0] : division by 0 (error token is " ")
./ginh.sh: line 101: freq[n]=counts[n] *     107     / counts[0] : division by 0 (error token is " ")
./ginh.sh: line 101: freq[n]=counts[n] *     107     / counts[0] : division by 0 (error token is " ")
./ginh.sh: line 101: freq[n]=counts[n] *     107     / counts[0] : division by 0 (error token is " ")
./ginh.sh: line 101: freq[n]=counts[n] *     107     / counts[0] : division by 0 (error token is " ")
./ginh.sh: line 101: freq[n]=counts[n] *     107     / counts[0] : division by 0 (error token is " ")
./ginh.sh: line 101: freq[n]=counts[n] *     107     / counts[0] : division by 0 (error token is " ")
./ginh.sh: line 101: freq[n]=counts[n] *     107     / counts[0] : division by 0 (error token is " ")
./ginh.sh: line 101: freq[n]=counts[n] *     107     / counts[0] : division by 0 (error token is " ")
./ginh.sh: line 101: freq[n]=counts[n] *     107     / counts[0] : division by 0 (error token is " ")
./ginh.sh: line 101: freq[n]=counts[n] *     107     / counts[0] : division by 0 (error token is " ")
./ginh.sh: line 101: freq[n]=counts[n] *     107     / counts[0] : division by 0 (error token is " ")
./ginh.sh: line 101: freq[n]=counts[n] *     107     / counts[0] : division by 0 (error token is " ")
./ginh.sh: line 101: freq[n]=counts[n] *     107     / counts[0] : division by 0 (error token is " ")
---------------------------------------------------------------------------------------------------------------
 =
 =
 =
 =
 =
 =
 =
 =
 =
 =
 =
 =
 =
 =
 =
---------------------------------------------------------------------------------------------------------------

[BUG] ./ginh.sh: line 95: -ci: command not found

When specifying the history file to use with the -f flag, ginh.sh prints an error message that states: ./ginh.sh: line 95: -ci: command not found. This occurs because when the file is specified, ginh doesn't attempt to determine the user's shell, but during alias reversal, it attempts to invoke the shell, which is not populated.

➜  ginh git:(master) ./ginh.sh -d               
commit: e79b710ce37fa0681854cdacd662b1ba7652761b
uname: Linux commodus 5.2.5-arch1-1-ARCH #1 SMP PREEMPT Wed Jul 31 08:30:34 UTC 2019 x86_64 GNU/Linux
shell: zsh
histfile: /home/ryan/.zsh_history

[REQUEST] Doas support

Is your feature request related to a problem? Please describe.
These days I primarily use doas, not sudo.

Describe the solution you'd like
A doas filter to match the existing sudo filter in functionality.

[BUG] Alias reversing breaks everything when 0 aliases exist

sed: 1: "s|\<_|g; ": unterminated substitute in regular expression
entries=1, file=/home/vagrant/.bash_history, char==, len=115
--------------------------------------------------------------------------------------------------------------------
 ================================================================================================================  1
--------------------------------------------------------------------------------------------------------------------
-bash-5.0$ alias
-bash-5.0$ echo "alias t='echo Hello'" >> ~/.bashrc
-bash-5.0$ source .bashrc
-bash: .bashrc: No such file or directory
-bash-5.0$ source ~/.bashrc
-bash-5.0$ t
Hello
-bash-5.0$ t
Hello
-bash-5.0$ t
Hello
-bash-5.0$ t
Hello
-bash-5.0$ t
Hello
-bash-5.0$ history -a
-bash-5.0$ ./ginh.sh 
entries=6, file=/home/vagrant/.bash_history, char==, len=115
--------------------------------------------------------------------------------------------------------------------
      git ======================================================================================================  11
     echo ========================================================  6
./ginh.sh ==============================================  5
  history ============================  3
       cd ==========  1
    alias ==========  1
--------------------------------------------------------------------------------------------------------------------
-bash-5.0$ 

Support for sudo

As an Ubuntu user, it would be nice if instead of detecting sudo apt get update as sudo it would count towards apt

Add support for fish shell

Great and useful script! Though when I tried it it did not work for fish shell :/

So I played around and via "quick fixes" I was able to run it on fish shell and there are 2 problems.

First is that line https://github.com/crclark96/ginh/blob/master/ginh.sh#L62 where variable$calc needs awk $3 instead of $1 -- grep -v -E '^\s*$|^\s+' $histfile | awk '{print $3}' | sort | uniq -c | sort -rn to work with fish history file.

Btw fish history file looks like

- cmd: git commit -v -a
  when: 1548438622
- cmd: git push origin master
  when: 1548438636
- cmd: fg
  when: 1548438726
- cmd: head fish_history
  when: 1548438886
  paths:
    - fish_history

And second problem is that $PPID doesn't work in fish shell or is empty. Plus line https://github.com/crclark96/ginh/blob/master/ginh.sh#L9 give strange error fish: Unknown command 'i'

That's all for quick report so yeah. This is awesome tool and it would be awesome have it supported by fish shell history logs. So yeah please add support for fish shell 🙏
Thanks ;)
ps: quick fixes - axeII@abd35aa

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.