aka2 0.1.10.pre → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/CODE_OF_CONDUCT.md +15 -0
- data/README.md +36 -20
- data/aka.gemspec +2 -1
- data/changelog.md +5 -7
- data/lib/aka.rb +54 -19
- data/lib/aka/config.rb +13 -9
- data/lib/aka/core.rb +2 -2
- data/lib/aka/dependencies.rb +2 -0
- data/lib/aka/helpers.rb +51 -32
- data/lib/aka/post_message.rb +0 -11
- data/lib/aka/printing.rb +9 -1
- data/lib/aka/version.rb +1 -1
- data/{lib → old}/.config +0 -0
- data/{.config → old/.config_ytbryan} +0 -0
- data/{aka → old/aka} +0 -0
- data/{bin → old}/console +0 -0
- data/{proj.aka → old/proj.aka} +0 -0
- data/{bin → old}/setup +0 -0
- data/old/something.aka +9 -0
- metadata +31 -26
- data/Gemfile +0 -4
- data/Gemfile.lock +0 -32
- data/assets/yes.png +0 -0
- data/install.sh +0 -25
- data/lib/aka2.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 43d8a5adbc547ef60802a765e0d8fd3fe7db66d7b0f3281aa97dfbc5a22ff9a7
|
4
|
+
data.tar.gz: 6f034350c2438808f4f806da7318eeb0ae376591ea6f486d0dc17f2d59b2f1a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa72d50eabbe19463c276c632e516b19098c98a8144335df0810a02938a173d9724ade81444b0ab44699940f9e7e54e97ceab8af376e16ac4c2ca0e7bdf036c9
|
7
|
+
data.tar.gz: 962782982746f7afc1d91cab5027743d5e3c1895dba85e45899b298a783716ceea247887bb3d50dc38d754c9fedeb74de141787026e2ff600c3cb81692fb64fa
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.3
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
Just be nice.
|
4
|
+
|
5
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
6
|
+
|
7
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
8
|
+
|
9
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
10
|
+
|
11
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
12
|
+
|
13
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
14
|
+
|
15
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/README.md
CHANGED
@@ -1,30 +1,37 @@
|
|
1
|
-
# Aka
|
2
|
-
|
3
|
-
### The Shortcut Manager for your Everyday Project
|
1
|
+
# Aka
|
4
2
|
|
5
3
|
[![Gem Version](https://badge.fury.io/rb/aka2.svg)](https://badge.fury.io/rb/aka2)
|
6
4
|
|
7
|
-
|
5
|
+
### Motivation
|
6
|
+
I use terminal with alias for work everyday. And I realise that to fully control my work flow, I would need to
|
7
|
+
manipulate the shortcuts in real time. Since there is no better way to control the shortcuts, I created my own.
|
8
|
+
|
9
|
+
Aka saves me time and allow me to achieve productivity through the creation of quick shortcut.
|
10
|
+
|
11
|
+
### The Workflow Manager for your Everyday Project
|
12
|
+
|
13
|
+
|
14
|
+
In other words, a delightful way to manage and grow your terminal shortcuts.
|
8
15
|
|
9
16
|
aka generate/edit/destroy/find permanent aliases with a single command.
|
10
17
|
|
11
18
|
aka requires ruby and is built for bash and zsh users.
|
12
19
|
|
13
|
-
|
|
14
|
-
| :-----------------------: |:----------------------------:|
|
15
|
-
| Generate alias |
|
16
|
-
| Destroy alias |
|
17
|
-
| Find and show alias |
|
18
|
-
| Show last few added alias | - |
|
19
|
-
| Edit alias | - |
|
20
|
-
| Count alias | - |
|
21
|
-
| Auto reload dot file | - |
|
22
|
-
| Show usage | - |
|
23
|
-
| Persistency | - |
|
24
|
-
| Add your last command | - |
|
25
|
-
| Export Alias | - |
|
26
|
-
| Group your Aliases | - |
|
27
|
-
| Add Alias to Project | - |
|
20
|
+
| Features | alias | aka |
|
21
|
+
| :-----------------------: |:----------------------------:| :---------------------:|
|
22
|
+
| Generate alias | ✅ | ✅ |
|
23
|
+
| Destroy alias | ✅ | ✅ |
|
24
|
+
| Find and show alias | ✅ | ✅ |
|
25
|
+
| Show last few added alias | - | ✅ |
|
26
|
+
| Edit alias | - | ✅ |
|
27
|
+
| Count alias | - | ✅ |
|
28
|
+
| Auto reload dot file | - | ✅ |
|
29
|
+
| Show usage | - | ✅ |
|
30
|
+
| Persistency | - | ✅ |
|
31
|
+
| Add your last command | - | ✅ |
|
32
|
+
| Export Alias | - | ✅ |
|
33
|
+
| Group your Aliases | - | ✅ |
|
34
|
+
| Add Alias to Project | - | ✅ |
|
28
35
|
|
29
36
|
## Installation
|
30
37
|
|
@@ -35,6 +42,8 @@ If you wish to setup aka again:
|
|
35
42
|
|
36
43
|
aka setup --reset
|
37
44
|
|
45
|
+
Note: You may need to use `sudo aka setup --reset`
|
46
|
+
|
38
47
|
## Usage
|
39
48
|
|
40
49
|
To generate new alias
|
@@ -79,6 +88,13 @@ To list all commands of aka
|
|
79
88
|
|
80
89
|
aka help
|
81
90
|
|
91
|
+
## Known issues
|
92
|
+
|
93
|
+
* aka is designed for controlling personal work flow. It is not ready for production server or multi-user environment.
|
94
|
+
|
95
|
+
* a missing `.bash_profile` file will require it to be created manually (ie `touch ~/.bash_profile`)
|
96
|
+
|
97
|
+
|
82
98
|
## Requirement
|
83
99
|
|
84
100
|
Ruby
|
@@ -93,4 +109,4 @@ Aka is released as an open source project under the license of [The MIT License
|
|
93
109
|
|
94
110
|
## Contact
|
95
111
|
|
96
|
-
[@ytbryan](http://www.twitter.com/ytbryan)
|
112
|
+
[@ytbryan](http://www.twitter.com/ytbryan) & 📮 Bryan Lim ytbryan@gmail.com
|
data/aka.gemspec
CHANGED
@@ -18,7 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
spec.post_install_message = Log::MESSAGE
|
20
20
|
spec.required_ruby_version = ">= 2.0.0"
|
21
|
-
spec.
|
21
|
+
spec.add_dependency 'thor' , '~> 0.19.4'
|
22
|
+
spec.add_dependency 'file-utils' , '~> 0.1.0'
|
22
23
|
spec.add_development_dependency "bundler", "~> 1.10"
|
23
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
25
|
spec.add_development_dependency "minitest", "~> 5.7"
|
data/changelog.md
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
+
# AKA
|
2
|
+
|
1
3
|
## v0.1.10
|
2
|
-
|
3
|
-
|
4
|
-
* Added [aka proj --save ] to generate specific aka file
|
5
|
-
* Added [aka proj] to show all project alias
|
6
|
-
* Added [aka groups] to list all groups in the system
|
4
|
+
added
|
5
|
+
|
7
6
|
* Added .profile as setup options. Thanks to fgperianez
|
8
|
-
* Edited test_aka.rb
|
9
7
|
* Refactor the aka code
|
10
8
|
* Remove some dependencies and set required ruby back to 2.0.0.
|
11
9
|
* Change default list to 20 aliases
|
12
|
-
*
|
10
|
+
* Fixed a bunch of issues. Thanks to noyannus https://github.com/ytbryan/aka/issues/14
|
13
11
|
|
14
12
|
## v0.1.9
|
15
13
|
* Added -g option to add grouping to alias
|
data/lib/aka.rb
CHANGED
@@ -5,11 +5,11 @@ require 'aka/printing'
|
|
5
5
|
require 'aka/core'
|
6
6
|
require 'aka/string'
|
7
7
|
require 'aka/config'
|
8
|
+
require 'aka/dependencies'
|
8
9
|
|
9
10
|
require 'yaml'
|
10
|
-
require 'thor'
|
11
11
|
require 'shellwords'
|
12
|
-
require '
|
12
|
+
require 'open-uri'
|
13
13
|
|
14
14
|
module Aka
|
15
15
|
class Base < Thor
|
@@ -24,7 +24,41 @@ module Aka
|
|
24
24
|
'e' => :edit,
|
25
25
|
'c' => :clean,
|
26
26
|
'h' => :help,
|
27
|
-
'v' => :version
|
27
|
+
'v' => :version,
|
28
|
+
'dl' => :download,
|
29
|
+
'func' => :function
|
30
|
+
|
31
|
+
desc :download, 'download a dotfile'
|
32
|
+
def download url
|
33
|
+
# open('image.png', 'wb') do |file|
|
34
|
+
# file << open('http://example.com/image.png').read
|
35
|
+
# end
|
36
|
+
|
37
|
+
system("curl -O #{url}")
|
38
|
+
end
|
39
|
+
|
40
|
+
desc :function, 'generate a function'
|
41
|
+
method_option :last, type: :boolean, aliases: '-l', desc: ''
|
42
|
+
method_option :group, type: :string, aliases: '-g', desc: '', default: 'default'
|
43
|
+
method_option :no, type: :boolean, aliases: '-n', desc: '--no means do not reload'
|
44
|
+
method_option :empty, type: :boolean, aliases: '-e', desc: 'do not print anything'
|
45
|
+
def function args
|
46
|
+
puts "function"
|
47
|
+
|
48
|
+
result = Aka.add_a_function(Aka.parseARGS(args), options[:group])
|
49
|
+
|
50
|
+
# result = false
|
51
|
+
# if options[:last] && args
|
52
|
+
# result = Aka.add_with_group(Aka.add_last_command(Aka.parseARGS(args)))
|
53
|
+
# else
|
54
|
+
# result = Aka.add_with_group(Aka.parseARGS(args), options[:group])
|
55
|
+
# end
|
56
|
+
Aka.reload_dot_file if result == true && !options[:no]
|
57
|
+
true
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
|
28
62
|
|
29
63
|
# desc :open, 'open my dotfile for development'
|
30
64
|
# def open
|
@@ -95,14 +129,14 @@ module Aka
|
|
95
129
|
method_option :no, type: :boolean, aliases: '-n', desc: '--no means do not reload'
|
96
130
|
method_option :empty, type: :boolean, aliases: '-e', desc: 'do not print anything'
|
97
131
|
def generate(args)
|
98
|
-
result =
|
132
|
+
result = false
|
99
133
|
if options[:last] && args
|
100
134
|
result = Aka.add_with_group(Aka.add_last_command(Aka.parseARGS(args)))
|
101
135
|
else
|
102
136
|
result = Aka.add_with_group(Aka.parseARGS(args), options[:group])
|
103
137
|
end
|
104
|
-
Aka.reload_dot_file if result ==
|
105
|
-
|
138
|
+
Aka.reload_dot_file if result == true && !options[:no]
|
139
|
+
true
|
106
140
|
end
|
107
141
|
|
108
142
|
#
|
@@ -115,18 +149,19 @@ module Aka
|
|
115
149
|
def destroy(*args)
|
116
150
|
args.each_with_index do |value, _index|
|
117
151
|
result = Aka.remove(value)
|
118
|
-
Aka.unalias_the(value) if !options[:nounalias] && result ==
|
119
|
-
Aka.reload_dot_file if result ==
|
152
|
+
Aka.unalias_the(value) if !options[:nounalias] && result == true
|
153
|
+
Aka.reload_dot_file if result == true && !options[:no]
|
120
154
|
end
|
121
|
-
|
155
|
+
true
|
122
156
|
end
|
123
157
|
|
124
158
|
#
|
125
159
|
# first step: set config file
|
126
160
|
#
|
127
|
-
desc :setup, '
|
161
|
+
desc :setup, 'setup aka'
|
128
162
|
method_options reset: :boolean
|
129
163
|
def setup
|
164
|
+
|
130
165
|
if options[:reset] && File.exist?("#{CONFIG_PATH}")
|
131
166
|
Aka.remove_autosource
|
132
167
|
FileUtils.rm_r("#{CONFIG_PATH}")
|
@@ -134,14 +169,14 @@ module Aka
|
|
134
169
|
end
|
135
170
|
|
136
171
|
if File.exist?("#{CONFIG_PATH}")
|
137
|
-
puts ".aka
|
138
|
-
puts 'Please run [aka setup --reset] to remove aka
|
172
|
+
puts ".aka exists at #{CONFIG_PATH}"
|
173
|
+
puts 'Please run [aka setup --reset] to remove .aka and setup again'
|
139
174
|
else
|
140
175
|
Aka.setup_config # create and setup .config file
|
141
176
|
Aka.setup_aka # put value in .config file
|
142
177
|
puts 'setting up autosource'
|
143
178
|
Aka.setup_autosource # create, link source file
|
144
|
-
puts "Congratulation, aka is setup
|
179
|
+
puts "Congratulation, aka is setup at #{CONFIG_PATH}"
|
145
180
|
end
|
146
181
|
end
|
147
182
|
|
@@ -159,7 +194,7 @@ module Aka
|
|
159
194
|
Aka.search_alias_return_alias_tokens(value)
|
160
195
|
end
|
161
196
|
end
|
162
|
-
|
197
|
+
true
|
163
198
|
end
|
164
199
|
|
165
200
|
#
|
@@ -177,7 +212,7 @@ module Aka
|
|
177
212
|
values = args.split('=')
|
178
213
|
if values.size > 1
|
179
214
|
truth, _alias = Aka.search_alias_return_alias_tokens(args)
|
180
|
-
if truth ==
|
215
|
+
if truth == true
|
181
216
|
if options[:name]
|
182
217
|
# Aka.remove(_alias) #remove that alias
|
183
218
|
Aka.edit_alias_name(values[1], _alias) # edit that alias
|
@@ -193,7 +228,7 @@ module Aka
|
|
193
228
|
else
|
194
229
|
puts "this is passed in #{args}"
|
195
230
|
truth, _alias, command, group = Aka.search_alias_return_alias_tokens_with_group(args)
|
196
|
-
if truth ==
|
231
|
+
if truth == true
|
197
232
|
if options[:name]
|
198
233
|
input = ask "Enter a new alias for command '#{command}'?\n"
|
199
234
|
if yes? 'Please confirm the new alias? (y/N)'
|
@@ -231,7 +266,7 @@ module Aka
|
|
231
266
|
Aka.showlast(options[:number], args.to_i, options[:group]) # user input
|
232
267
|
else
|
233
268
|
value = Aka.readYML("#{CONFIG_PATH}")['list']
|
234
|
-
if value.class ==
|
269
|
+
if value.class == Integer
|
235
270
|
Aka.showlast(options[:number], value.to_i, options[:group])
|
236
271
|
else
|
237
272
|
puts "List value is not defined in #{CONFIG_PATH}"
|
@@ -249,14 +284,14 @@ module Aka
|
|
249
284
|
def usage(args = nil)
|
250
285
|
if args
|
251
286
|
if options[:least] && args
|
252
|
-
Aka.showUsage(args.to_i,
|
287
|
+
Aka.showUsage(args.to_i, true)
|
253
288
|
else
|
254
289
|
Aka.showUsage(args.to_i)
|
255
290
|
end
|
256
291
|
else
|
257
292
|
if options[:least]
|
258
293
|
value = Aka.readYML("#{CONFIG_PATH}")['usage']
|
259
|
-
Aka.showlast(value.to_i,
|
294
|
+
Aka.showlast(value.to_i, true) # this is unsafe
|
260
295
|
else
|
261
296
|
value = Aka.readYML("#{CONFIG_PATH}")['usage']
|
262
297
|
Aka.howlast(value.to_i) # this is unsafe
|
data/lib/aka/config.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
require_relative './dependencies.rb'
|
2
2
|
|
3
|
+
module Aka
|
3
4
|
def self.setup_aka
|
4
5
|
userBash = []
|
5
6
|
# 1. check for each type of file without setting anything.
|
@@ -25,11 +26,12 @@ module Aka
|
|
25
26
|
elsif userBash.count > 1
|
26
27
|
#4 if the number of types is more than 1, proceed to ask which one does the users want to uses.
|
27
28
|
userBash.each_with_index do |choice,i|
|
28
|
-
puts "#{i+1}. Setup
|
29
|
+
puts "#{i+1}. Setup at #{Dir.home}/#{choice}"
|
29
30
|
end
|
30
|
-
choice = ask "Please choose which location you wish to setup? (Choose a number and enter)\n"
|
31
31
|
|
32
|
-
|
32
|
+
puts ("Where do you wish to setup aka? (Pick a number and enter)\n")
|
33
|
+
choice = STDIN.gets.chomp
|
34
|
+
|
33
35
|
case choice
|
34
36
|
when "1"
|
35
37
|
set_to_dotfile(userBash[0]) if userBash[0]
|
@@ -71,15 +73,16 @@ module Aka
|
|
71
73
|
end
|
72
74
|
|
73
75
|
def self.setup_autosource
|
74
|
-
if File.exist?("#{
|
75
|
-
|
76
|
+
if File.exist?("#{AKA_PATH}")
|
77
|
+
FileUtils.touch("#{AKA_PATH}/autosource")
|
78
|
+
out_file = File.new("#{AKA_PATH}/autosource", "w")
|
76
79
|
out_file.puts("export HISTSIZE=10000")
|
77
80
|
out_file.puts("sigusr2() { unalias $1;}")
|
78
81
|
out_file.puts("sigusr1() { source #{readYML("#{CONFIG_PATH}")["dotfile"]}; history -a; echo 'reloaded dot file'; }")
|
79
82
|
out_file.puts("trap sigusr1 SIGUSR1")
|
80
83
|
out_file.puts("trap 'sigusr2 $(cat ~/sigusr1-args)' SIGUSR2")
|
81
84
|
out_file.close
|
82
|
-
autosource = "\nsource \"#{
|
85
|
+
autosource = "\nsource \"#{AKA_PATH}/autosource\""
|
83
86
|
append(autosource, readYML("#{CONFIG_PATH}")['profile'])
|
84
87
|
puts "Done. Please restart this shell.".red
|
85
88
|
else
|
@@ -90,7 +93,8 @@ module Aka
|
|
90
93
|
if File.exist?("#{CONFIG_PATH}")
|
91
94
|
puts "Directory #{CONFIG_PATH} exist"
|
92
95
|
else
|
93
|
-
FileUtils
|
96
|
+
FileUtils.mkdir_p("#{AKA_PATH}")
|
97
|
+
FileUtils.touch("#{CONFIG_PATH}")
|
94
98
|
out_file = File.new("#{CONFIG_PATH}", "w")
|
95
99
|
out_file.puts("---")
|
96
100
|
out_file.puts("dotfile: \"/home/user/.bashrc\"")
|
@@ -160,7 +164,7 @@ module Aka
|
|
160
164
|
end
|
161
165
|
|
162
166
|
def self.isOhMyZsh
|
163
|
-
readYML("#{CONFIG_PATH}")["dotfile"] == "#{ZSHRC_PATH}" ?
|
167
|
+
readYML("#{CONFIG_PATH}")["dotfile"] == "#{ZSHRC_PATH}" ? true : false
|
164
168
|
end
|
165
169
|
|
166
170
|
end
|
data/lib/aka/core.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Aka
|
2
2
|
def self.reload_dot_file
|
3
|
-
isOhMyZsh ==
|
3
|
+
isOhMyZsh == true ? system("exec zsh") : system("kill -SIGUSR1 #{Process.ppid}")
|
4
4
|
end
|
5
5
|
|
6
6
|
def self.unalias_the value
|
7
|
-
if isOhMyZsh ==
|
7
|
+
if isOhMyZsh == true
|
8
8
|
system("exec zsh")
|
9
9
|
else
|
10
10
|
system "echo '#{value}' > ~/sigusr1-args;"
|
data/lib/aka/helpers.rb
CHANGED
@@ -45,7 +45,7 @@ module Aka
|
|
45
45
|
|
46
46
|
def self.setPath(path, value)
|
47
47
|
data = readYML("#{CONFIG_PATH}")
|
48
|
-
if data.has_key?(value) ==
|
48
|
+
if data.has_key?(value) == true
|
49
49
|
old_path = data[value]
|
50
50
|
data[value] = path
|
51
51
|
writeYML("#{CONFIG_PATH}", data)
|
@@ -117,8 +117,27 @@ module Aka
|
|
117
117
|
return [username, domain, port]
|
118
118
|
end
|
119
119
|
|
120
|
+
def self.add_a_function input, name_of_group
|
121
|
+
if input && search_alias_return_alias_tokens(input).first == false && not_empty_alias(input) == false
|
122
|
+
array = input.split("=")
|
123
|
+
group_name = "# => #{name_of_group}"
|
124
|
+
|
125
|
+
full_command = "function #{array.first}(){ #{array[1]} } #{group_name}".gsub("\n","") #remove new line in command
|
126
|
+
|
127
|
+
# full_command = "alias #{array.first}='#{array[1]}' #{group_name}".gsub("\n","") #remove new line in command
|
128
|
+
print_out_command = "aka g #{array.first}='#{array[1]}'"
|
129
|
+
str = is_config_file_present?(readYML("#{CONFIG_PATH}")["dotfile"])
|
130
|
+
File.open(str, 'a') { |file| file.write("\n" +full_command) }
|
131
|
+
create_statement "#{print_out_command} " + "in #{name_of_group} group."
|
132
|
+
return true
|
133
|
+
else
|
134
|
+
puts "The alias is already present. Use 'aka -h' to see all the useful commands."
|
135
|
+
return false
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
120
139
|
def self.add_with_group input, name_of_group
|
121
|
-
if input && search_alias_return_alias_tokens(input).first ==
|
140
|
+
if input && search_alias_return_alias_tokens(input).first == false && not_empty_alias(input) == false
|
122
141
|
array = input.split("=")
|
123
142
|
group_name = "# => #{name_of_group}"
|
124
143
|
full_command = "alias #{array.first}='#{array[1]}' #{group_name}".gsub("\n","") #remove new line in command
|
@@ -126,31 +145,31 @@ module Aka
|
|
126
145
|
str = is_config_file_present?(readYML("#{CONFIG_PATH}")["dotfile"])
|
127
146
|
File.open(str, 'a') { |file| file.write("\n" +full_command) }
|
128
147
|
create_statement "#{print_out_command} " + "in #{name_of_group} group."
|
129
|
-
return
|
148
|
+
return true
|
130
149
|
else
|
131
150
|
puts "The alias is already present. Use 'aka -h' to see all the useful commands."
|
132
|
-
return
|
151
|
+
return false
|
133
152
|
end
|
134
153
|
end
|
135
154
|
|
136
155
|
def self.add input
|
137
|
-
if input && search_alias_return_alias_tokens(input).first ==
|
156
|
+
if input && search_alias_return_alias_tokens(input).first == false && not_empty_alias(input) == false
|
138
157
|
array = input.split("=")
|
139
158
|
full_command = "alias #{array.first}='#{array[1]}'".gsub("\n","") #remove new line in command
|
140
159
|
print_out_command = "aka g #{array.first}='#{array[1]}'"
|
141
160
|
str = is_config_file_present?(readYML("#{CONFIG_PATH}")["dotfile"])
|
142
161
|
File.open(str, 'a') { |file| file.write("\n" +full_command) }
|
143
162
|
create_statement "#{print_out_command}"
|
144
|
-
return
|
163
|
+
return true
|
145
164
|
else
|
146
165
|
puts "The alias is already present. Use 'aka -h' to see all the useful commands."
|
147
|
-
return
|
166
|
+
return false
|
148
167
|
end
|
149
168
|
end
|
150
169
|
|
151
170
|
def self.not_empty_alias input
|
152
171
|
array = input.split("=")
|
153
|
-
return
|
172
|
+
return true if array.count < 2
|
154
173
|
return array[1].strip == ""
|
155
174
|
end
|
156
175
|
|
@@ -242,19 +261,19 @@ module Aka
|
|
242
261
|
containsCommand = line.split('=') #containsCommand[1]
|
243
262
|
if value.length > 1 && value.first == "alias"
|
244
263
|
answer = value[1].split("=") #contains the alias
|
245
|
-
if found?(answer.first, argument.split("=").first, line) ==
|
264
|
+
if found?(answer.first, argument.split("=").first, line) == true
|
246
265
|
this_alias = answer.first
|
247
266
|
answer.slice!(0) #rmove the first
|
248
267
|
containsCommand[1].slice!(0) && containsCommand[1].slice!(containsCommand[1].length-1) if containsCommand[1] != nil && containsCommand[1][0] == "'" && containsCommand[1][containsCommand[1].length-1] == "'"
|
249
|
-
return [
|
268
|
+
return [true, this_alias, containsCommand[1]]
|
250
269
|
end
|
251
270
|
end
|
252
271
|
}
|
253
272
|
else
|
254
273
|
puts "#{@pwd} cannot be found.".red
|
255
|
-
return [
|
274
|
+
return [false, nil, nil]
|
256
275
|
end
|
257
|
-
return [
|
276
|
+
return [false, nil, nil]
|
258
277
|
|
259
278
|
end
|
260
279
|
|
@@ -270,20 +289,20 @@ module Aka
|
|
270
289
|
containsCommand = templine.split('=') #containsCommand[1]
|
271
290
|
group_name = get_group_name(line)
|
272
291
|
answer = value[1].split("=") #contains the alias
|
273
|
-
if found?(answer.first, argument.split("=").first, templine) ==
|
292
|
+
if found?(answer.first, argument.split("=").first, templine) == true
|
274
293
|
this_alias = answer.first
|
275
294
|
answer.slice!(0) #rmove the first
|
276
295
|
containsCommand[1].strip!
|
277
296
|
containsCommand[1].slice!(0) && containsCommand[1].slice!(containsCommand[1].length-1) if containsCommand[1] != nil && containsCommand[1][0] == "'" && containsCommand[1][containsCommand[1].length-1] == "'"
|
278
|
-
return [
|
297
|
+
return [true, this_alias, containsCommand[1], group_name]
|
279
298
|
end
|
280
299
|
end
|
281
300
|
}
|
282
301
|
else
|
283
302
|
puts "#{@pwd} cannot be found.".red
|
284
|
-
return [
|
303
|
+
return [false, nil, nil, nil]
|
285
304
|
end
|
286
|
-
return [
|
305
|
+
return [false, nil, nil, nil]
|
287
306
|
end
|
288
307
|
|
289
308
|
def self.remove input
|
@@ -299,7 +318,7 @@ module Aka
|
|
299
318
|
content_array.delete_at(index) && write_with_newline(content_array)
|
300
319
|
print_out_command = "aka g #{input}=#{line.split("=")[1]}"
|
301
320
|
puts "Removed: ".red + "#{print_out_command}"
|
302
|
-
return
|
321
|
+
return true
|
303
322
|
end
|
304
323
|
end
|
305
324
|
}
|
@@ -307,7 +326,7 @@ module Aka
|
|
307
326
|
puts "#{input} cannot be found.".red
|
308
327
|
else
|
309
328
|
puts "#{@pwd} cannot be found.".red
|
310
|
-
return
|
329
|
+
return false
|
311
330
|
end
|
312
331
|
end
|
313
332
|
|
@@ -319,12 +338,12 @@ module Aka
|
|
319
338
|
if line == "source \"/home/ryan/.aka/autosource\""
|
320
339
|
content_array.delete_at(index) && write_with_newline(content_array)
|
321
340
|
puts "Removed: ".red + "source \"/home/ryan/.aka/autosource\""
|
322
|
-
return
|
341
|
+
return true
|
323
342
|
end
|
324
343
|
}
|
325
344
|
else
|
326
345
|
error_statement("autosource cannot be found in dotfile.")
|
327
|
-
return
|
346
|
+
return false
|
328
347
|
end
|
329
348
|
end
|
330
349
|
|
@@ -350,9 +369,9 @@ module Aka
|
|
350
369
|
def self.found? answer, argument, line
|
351
370
|
if answer == argument
|
352
371
|
exist_statement(" aka g #{argument}=#{line.split('=')[1]}")
|
353
|
-
return
|
372
|
+
return true
|
354
373
|
else
|
355
|
-
return
|
374
|
+
return false
|
356
375
|
end
|
357
376
|
end
|
358
377
|
|
@@ -457,7 +476,7 @@ module Aka
|
|
457
476
|
|
458
477
|
def self.read location
|
459
478
|
answer = File.exist?(location)
|
460
|
-
answer ==
|
479
|
+
answer == true && content = File.open(location).read ? content : ""
|
461
480
|
end
|
462
481
|
|
463
482
|
def self.is_config_file_present? str
|
@@ -474,7 +493,7 @@ module Aka
|
|
474
493
|
return str
|
475
494
|
end
|
476
495
|
|
477
|
-
def self.showlast(list_number=
|
496
|
+
def self.showlast(list_number=false,howmany=10, showGroup)
|
478
497
|
str = is_config_file_present?(readYML("#{CONFIG_PATH}")["dotfile"])
|
479
498
|
if content = File.open(str).read
|
480
499
|
content_array = product_content_array(content)
|
@@ -512,7 +531,7 @@ module Aka
|
|
512
531
|
end
|
513
532
|
end
|
514
533
|
|
515
|
-
def self.showUsage howmany=10, least=
|
534
|
+
def self.showUsage howmany=10, least=false
|
516
535
|
str = is_config_file_present?(readYML("#{CONFIG_PATH}")["history"])
|
517
536
|
value = reload_dot_file
|
518
537
|
#get all aliases
|
@@ -527,10 +546,10 @@ module Aka
|
|
527
546
|
end
|
528
547
|
end
|
529
548
|
|
530
|
-
def self.count_aliases array, howmany, least=
|
549
|
+
def self.count_aliases array, howmany, least=false
|
531
550
|
name_array,count_array = [], []
|
532
551
|
array.each_with_index { |value, index|
|
533
|
-
if name_array.include?(value) ==
|
552
|
+
if name_array.include?(value) == false
|
534
553
|
name_array.push(value)
|
535
554
|
end
|
536
555
|
}
|
@@ -548,7 +567,7 @@ module Aka
|
|
548
567
|
sorted_count_array, sorted_name_array = sort(count_array, name_array)
|
549
568
|
|
550
569
|
#display the least used aliases
|
551
|
-
if least ==
|
570
|
+
if least == true
|
552
571
|
if sorted_count_array.count == sorted_name_array.count
|
553
572
|
puts ""
|
554
573
|
sorted_name_array.last(howmany).each_with_index { |value, index|
|
@@ -605,13 +624,13 @@ module Aka
|
|
605
624
|
str = is_config_file_present?(readYML("#{CONFIG_PATH}")["dotfile"])
|
606
625
|
if content = File.open(str).read
|
607
626
|
content_array = product_content_array(content)
|
608
|
-
check =
|
609
|
-
while check ==
|
610
|
-
check =
|
627
|
+
check = false
|
628
|
+
while check == false
|
629
|
+
check = true
|
611
630
|
content_array.each_with_index { |line, index|
|
612
631
|
if line == "" || line == "\n"
|
613
632
|
content_array.delete_at(index)
|
614
|
-
check =
|
633
|
+
check = false
|
615
634
|
end
|
616
635
|
}
|
617
636
|
end
|
data/lib/aka/post_message.rb
CHANGED
@@ -9,17 +9,6 @@ module Log
|
|
9
9
|
╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝
|
10
10
|
###############################
|
11
11
|
|
12
|
-
## What's new in 0.1.10?
|
13
|
-
* `aka proj`
|
14
|
-
* `aka proj --save`
|
15
|
-
* `aka proj --load`
|
16
|
-
* Introduce Project Aliases, System Aliases and Groups
|
17
|
-
* Added [aka proj --load] to export certain alias group into a project directory
|
18
|
-
* Added [aka proj --save ] to generate specific aka file
|
19
|
-
* Added [aka proj] to show all project alias
|
20
|
-
* Added [aka groups] to list all groups in the system
|
21
|
-
* Added .profile as setup options. Thanks to fgperianez
|
22
|
-
|
23
12
|
Full Changelog -> https://github.com/ytbryan/aka/blob/master/changelog.md
|
24
13
|
|
25
14
|
Pull Request -> https://github.com/ytbryan/aka/pulls
|
data/lib/aka/printing.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
+
#################################
|
2
|
+
# Bryan Lim (@ytbryan)
|
3
|
+
# MIT License
|
4
|
+
# github.com/ytbryan
|
5
|
+
# twitter.com/ytbryan
|
6
|
+
# ytbryan@gmail.com || ytbryan@u.nus.edu
|
7
|
+
#################################
|
8
|
+
|
1
9
|
module Aka
|
2
10
|
def self.exist_statement(statement)
|
3
|
-
puts "
|
11
|
+
puts "Exist: ".green + statement
|
4
12
|
end
|
5
13
|
|
6
14
|
def self.print_all_helpful_statement
|
data/lib/aka/version.rb
CHANGED
data/{lib → old}/.config
RENAMED
File without changes
|
File without changes
|
data/{aka → old/aka}
RENAMED
File without changes
|
data/{bin → old}/console
RENAMED
File without changes
|
data/{proj.aka → old/proj.aka}
RENAMED
File without changes
|
data/{bin → old}/setup
RENAMED
File without changes
|
data/old/something.aka
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
#generated with https://rubygems.org/gems/aka2
|
2
|
+
|
3
|
+
alias contr='rails g controller' # => rails
|
4
|
+
alias mod='rails g model' # => rails
|
5
|
+
alias migrate='rake db:create; rake db:migrate;' # => rails
|
6
|
+
alias unlock='rm Gemfile.lock' # => rails
|
7
|
+
alias bundleup='bundle install' # => rails
|
8
|
+
alias server='rails server' # => rails
|
9
|
+
alias res='rails g scaffold' # => rails
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aka2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.10
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Lim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.19.
|
19
|
+
version: 0.19.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.19.
|
26
|
+
version: 0.19.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: file-utils
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,47 +89,39 @@ executables:
|
|
75
89
|
extensions: []
|
76
90
|
extra_rdoc_files: []
|
77
91
|
files:
|
78
|
-
- ".config"
|
79
92
|
- ".gitignore"
|
80
93
|
- ".ruby-version"
|
81
|
-
-
|
82
|
-
- Gemfile.lock
|
94
|
+
- CODE_OF_CONDUCT.md
|
83
95
|
- LICENSE.txt
|
84
96
|
- README.md
|
85
97
|
- Rakefile
|
86
|
-
- aka
|
87
98
|
- aka.gemspec
|
88
|
-
- assets/yes.png
|
89
99
|
- bin/aka
|
90
|
-
- bin/console
|
91
|
-
- bin/setup
|
92
100
|
- changelog.md
|
93
|
-
- install.sh
|
94
|
-
- lib/.config
|
95
101
|
- lib/aka.rb
|
96
102
|
- lib/aka/config.rb
|
97
103
|
- lib/aka/constants.rb
|
98
104
|
- lib/aka/core.rb
|
105
|
+
- lib/aka/dependencies.rb
|
99
106
|
- lib/aka/helpers.rb
|
100
107
|
- lib/aka/post_message.rb
|
101
108
|
- lib/aka/printing.rb
|
102
109
|
- lib/aka/string.rb
|
103
110
|
- lib/aka/version.rb
|
104
|
-
-
|
105
|
-
-
|
111
|
+
- old/.config
|
112
|
+
- old/.config_ytbryan
|
113
|
+
- old/aka
|
114
|
+
- old/console
|
115
|
+
- old/proj.aka
|
116
|
+
- old/setup
|
117
|
+
- old/something.aka
|
106
118
|
homepage: https://github.com/ytbryan/aka
|
107
119
|
licenses:
|
108
120
|
- MIT
|
109
121
|
metadata: {}
|
110
122
|
post_install_message: "\n\n █████╗ ██╗ ██╗ █████╗\n ██╔══██╗██║ ██╔╝██╔══██╗\n ███████║█████╔╝
|
111
123
|
███████║\n ██╔══██║██╔═██╗ ██╔══██║\n ██║ ██║██║ ██╗██║ ██║\n ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝
|
112
|
-
\ ╚═╝\n###############################\n\n
|
113
|
-
\ * `aka proj --save`\n * `aka proj --load`\n * Introduce Project Aliases, System
|
114
|
-
Aliases and Groups\n * Added [aka proj --load] to export certain alias group into
|
115
|
-
a project directory\n * Added [aka proj --save ] to generate specific aka file\n
|
116
|
-
\ * Added [aka proj] to show all project alias\n * Added [aka groups] to list all
|
117
|
-
groups in the system\n * Added .profile as setup options. Thanks to fgperianez\n\n
|
118
|
-
\ Full Changelog -> https://github.com/ytbryan/aka/blob/master/changelog.md\n\n
|
124
|
+
\ ╚═╝\n###############################\n\n Full Changelog -> https://github.com/ytbryan/aka/blob/master/changelog.md\n\n
|
119
125
|
\ Pull Request -> https://github.com/ytbryan/aka/pulls\n "
|
120
126
|
rdoc_options: []
|
121
127
|
require_paths:
|
@@ -127,12 +133,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
133
|
version: 2.0.0
|
128
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
135
|
requirements:
|
130
|
-
- - "
|
136
|
+
- - ">="
|
131
137
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
138
|
+
version: '0'
|
133
139
|
requirements: []
|
134
|
-
|
135
|
-
rubygems_version: 2.4.8
|
140
|
+
rubygems_version: 3.0.3
|
136
141
|
signing_key:
|
137
142
|
specification_version: 4
|
138
143
|
summary: The Missing Shortcut Manager
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
aka2 (0.1.8)
|
5
|
-
colorize (~> 0)
|
6
|
-
net-scp (~> 1.2, >= 1.2.1)
|
7
|
-
safe_yaml (~> 1.0, >= 1.0.4)
|
8
|
-
thor (~> 0.19.1)
|
9
|
-
|
10
|
-
GEM
|
11
|
-
remote: https://rubygems.org/
|
12
|
-
specs:
|
13
|
-
colorize (0.7.7)
|
14
|
-
minitest (5.7.0)
|
15
|
-
net-scp (1.2.1)
|
16
|
-
net-ssh (>= 2.6.5)
|
17
|
-
net-ssh (2.9.2)
|
18
|
-
rake (10.4.2)
|
19
|
-
safe_yaml (1.0.4)
|
20
|
-
thor (0.19.1)
|
21
|
-
|
22
|
-
PLATFORMS
|
23
|
-
ruby
|
24
|
-
|
25
|
-
DEPENDENCIES
|
26
|
-
aka2!
|
27
|
-
bundler (~> 1.10)
|
28
|
-
minitest (~> 5.7)
|
29
|
-
rake (~> 10.0)
|
30
|
-
|
31
|
-
BUNDLED WITH
|
32
|
-
1.10.6
|
data/assets/yes.png
DELETED
Binary file
|
data/install.sh
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
|
2
|
-
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
3
|
-
sudo apt-get install git
|
4
|
-
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
5
|
-
#mac os x
|
6
|
-
brew install git
|
7
|
-
fi
|
8
|
-
|
9
|
-
#clone rbenv
|
10
|
-
git clone https://github.com/sstephenson/rbenv.git
|
11
|
-
|
12
|
-
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
13
|
-
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
|
14
|
-
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
|
15
|
-
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
16
|
-
#mac os x
|
17
|
-
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
|
18
|
-
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
|
19
|
-
echo 'Mac OSX'
|
20
|
-
fi
|
21
|
-
|
22
|
-
#install ruby
|
23
|
-
rbenv install 2.2.3
|
24
|
-
|
25
|
-
gem install bundler rails
|
data/lib/aka2.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'aka/version'
|
2
|
-
require 'yaml'
|
3
|
-
require 'thor'
|
4
|
-
require 'shellwords'
|
5
|
-
require 'fileutils'
|
6
|
-
|
7
|
-
module Aka2
|
8
|
-
class Base < Thor
|
9
|
-
check_unknown_options!
|
10
|
-
package_name "aka"
|
11
|
-
default_task :list
|
12
|
-
map "g" => "generate",
|
13
|
-
"d" => "destroy",
|
14
|
-
"f" => "find",
|
15
|
-
"u" => "usage",
|
16
|
-
"l" => "list",
|
17
|
-
"e" => "edit",
|
18
|
-
"c" => "clean",
|
19
|
-
"h" => "help"
|
20
|
-
|
21
|
-
desc "generate", ""
|
22
|
-
def generate the_name=""
|
23
|
-
puts "boo"
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|