-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon_ruby_shell.rb
More file actions
43 lines (36 loc) · 835 Bytes
/
common_ruby_shell.rb
File metadata and controls
43 lines (36 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require "#{ENV['HOME']}/aki_colours"
# application name
def app_prompt
rails_klass = Rails.application.class
app_name =
if rails_klass.respond_to? :module_parent
rails_klass.module_parent
else
rails_klass.parent
end
"#{bold}#{lcyan}#{app_name.name.underscore}#{reset}"
end
def env_prompt
env =
case Rails.env
when "development"
"#{green}dev"
when "production"
"#{lred}prod"
else
"#{cyan}#{Rails.env}"
end
"#{bold}#{env}#{reset}"
end
# target log path for irb history
def log_path
rails_root = Rails.root
"#{rails_root}/log/.irb-save-history"
end
# pbcopy helper: Copied from: https://stackoverflow.com/a/46065116/5863438
def pbcopy(arg)
out = arg.is_a?(String) ? arg : arg.inspect
IO.popen('pbcopy', 'w') { |io| io.puts out }
puts out
true
end