Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl
- use strict;
- use warnings;
- use File::Basename 'basename';
- sub get_cmds_shell_history()
- {
- # Call bash interactive mode and call history built-in
- my $get_cmds =
- qq/$ENV{'SHELL'} -i -c "history -r; history"/
- . q/ | awk '{ print $2 }'/
- . q/ | awk -F\| '{ print $1 }'/; # Choice first pipe command
- chomp(my @cmds = qx# $get_cmds #);
- return @cmds ? @cmds : undef;
- }
- my %cmds_grouped = ();
- (m|/|) ? $cmds_grouped{ basename($_) }++ : $cmds_grouped{$_}++
- for (get_cmds_shell_history);
- # Popularity sorted decrease order
- printf("% 8d %s\n", $cmds_grouped{$_}, $_)
- for sort { $cmds_grouped{$b} <=> $cmds_grouped{$a} }
- keys %cmds_grouped;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement