alias-manager 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/alias-manager +5 -0
- data/lib/alias_manager.rb +27 -0
- data/lib/alias_manager/alias.rb +22 -0
- data/lib/alias_manager/log_line.rb +17 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a7f1d554c38bda992ad3ea7a07b6f7ebf5f68a25
|
4
|
+
data.tar.gz: 2d8e4995de0cf8988c74ddf6f7265c7e7162a7f2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9362f6007a1280d4575f95298adc37ea392bb569cd9c775b00f724112b0942d2450d3f3c8a296d530749e6a7ccb0453a20f7b32f197aa5364f18d6e7617d2c59
|
7
|
+
data.tar.gz: c1f46ed7926c9aa9e21e7b9e5ed4eafa0b1e6eb4e9dfddbdd05257a124d2f77266f94710f353000bb29c0e716b300f5ae1a8a038163eb599ffc7840abb763e87
|
data/bin/alias-manager
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative 'alias_manager/alias'
|
2
|
+
require_relative 'alias_manager/log_line'
|
3
|
+
|
4
|
+
module AliasManager
|
5
|
+
|
6
|
+
def self.run
|
7
|
+
commands_by_counts = LogLine.counts
|
8
|
+
|
9
|
+
unused_aliases = Alias.all.select do |aliaz|
|
10
|
+
commands_by_counts[aliaz.abbreviation] == nil
|
11
|
+
end
|
12
|
+
|
13
|
+
puts "You have never used these aliases in the past #{LogLine.all.count} commands:"
|
14
|
+
puts unused_aliases.map(&:string)
|
15
|
+
|
16
|
+
puts "You should remove them from your zshrc."
|
17
|
+
|
18
|
+
used_once_aliases = Alias.all.select do |aliaz|
|
19
|
+
commands_by_counts[aliaz.abbreviation] == 1
|
20
|
+
end
|
21
|
+
|
22
|
+
3.times { puts '' }
|
23
|
+
puts "You have used these aliases only once in the past #{LogLine.all.count} commands:"
|
24
|
+
puts used_once_aliases.map(&:string)
|
25
|
+
puts "You should use them more, or consider removing them from your zshrc."
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module AliasManager
|
2
|
+
class Alias < Struct.new(:string)
|
3
|
+
|
4
|
+
def self.all
|
5
|
+
@all ||= `echo "source #{ENV['HOME']}/.zshrc; alias -L" | /bin/zsh`.split("\n").select do |alias_line|
|
6
|
+
alias_line[/alias\s+[^=]*=/]
|
7
|
+
end.map do |string|
|
8
|
+
new(string)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def abbreviation
|
13
|
+
string.match(/alias\s+([^=]*)=/)[1]
|
14
|
+
end
|
15
|
+
|
16
|
+
def command
|
17
|
+
string.match(/='?"?([^'"]*)'?"?/)[1]
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module AliasManager
|
2
|
+
class LogLine
|
3
|
+
def self.all
|
4
|
+
logs = File.readlines("#{ENV['HOME']}/.zsh_history")
|
5
|
+
|
6
|
+
logs.map do |log_line|
|
7
|
+
log_line.force_encoding("iso-8859-1").split(";").last.chomp.split(" ").first
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.counts
|
12
|
+
all.group_by { |command| command }.map do |command, commands|
|
13
|
+
[command, commands.count]
|
14
|
+
end.to_h
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: alias-manager
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Victor Mours
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-13 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Alias Manager finds which of your aliases are unused and which ones can
|
14
|
+
be improved
|
15
|
+
email: victor.mours@gmail.com
|
16
|
+
executables:
|
17
|
+
- alias-manager
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- bin/alias-manager
|
22
|
+
- lib/alias_manager.rb
|
23
|
+
- lib/alias_manager/alias.rb
|
24
|
+
- lib/alias_manager/log_line.rb
|
25
|
+
homepage:
|
26
|
+
licenses:
|
27
|
+
- MIT
|
28
|
+
metadata: {}
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubyforge_project:
|
45
|
+
rubygems_version: 2.4.5
|
46
|
+
signing_key:
|
47
|
+
specification_version: 4
|
48
|
+
summary: Better shell alias management
|
49
|
+
test_files: []
|