yap-shell-addon-prompt-refresh 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +61 -0
- data/Rakefile +6 -0
- data/lib/yap-shell-addon-prompt-refresh.rb +56 -0
- data/lib/yap-shell-addon-prompt-refresh/version.rb +3 -0
- data/yap-shell-addon-prompt-refresh.gemspec +27 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a452ea20f5c284b4aec365ac271a217f497a50c1
|
4
|
+
data.tar.gz: 404db831ef2fdaa0038d250733df1f8b6685d5c9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7717ac8ba43b2c472dacd1d0cf8a137b5678edd38affd541a9a537b4625ad702ab955f8ee1af92195366597b0d5c9fbba989936723cb326ee8c49e648599302c
|
7
|
+
data.tar.gz: a663ba362f7505f7bc4c0f021b5dee530f0c19b2850a611a7ed2cb17960c2575b2bc40814745975ee2323d81b6e73027001a5d463820b35044af1a8d162de6c2
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
wiki/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Zach Dennis
|
4
|
+
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
14
|
+
all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# prompt-refresh for yap-shell
|
2
|
+
|
3
|
+
prompt-refresh is a yap-shell addon that automatically refreshes your prompt.
|
4
|
+
|
5
|
+
By default, it will refresh it every 100 milliseconds, but this is configurable thru your `yaprc` file.
|
6
|
+
|
7
|
+
![Prompt live refreshes across shell instances](/yap-shell-addon-prompt-refresh.gif?raw=true)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Within the yap-shell you can install it as an addon via:
|
12
|
+
|
13
|
+
$ yap addon install prompt-refresh
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ reload!
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install yap-shell-addon-prompt-refresh
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
If you have customized your yap-shell prompt to be a lambda/proc then it is possible to have yap automatically refresh it.
|
26
|
+
|
27
|
+
For example, say you put your current git branch into your prompt and you wanted every shell session you had open to always have the up-to-date branch displayed (without you having to do a thing).
|
28
|
+
|
29
|
+
You might have your prompt configured like this in your `~/.yap/yaprc` file:
|
30
|
+
|
31
|
+
world.prompt = -> do
|
32
|
+
# use ~ instead of full-path to home directory
|
33
|
+
pwd = Dir.pwd.sub Regexp.new(ENV['HOME']), '~'
|
34
|
+
|
35
|
+
# identify our current branch
|
36
|
+
git_current_branch = `git branch 2>/dev/null | sed -n '/\* /s///p'`.chomp
|
37
|
+
|
38
|
+
# is the current directory a part of a git enabled directory structure?
|
39
|
+
is_git_aware = git_current_branch.length > 0
|
40
|
+
|
41
|
+
git_branch = is_git_aware ? cyan(git_current_branch) : ''
|
42
|
+
|
43
|
+
# E.g. ~/source/my-project master $
|
44
|
+
"#{yellow(pwd)} #{git_branch} $ "
|
45
|
+
end
|
46
|
+
|
47
|
+
After install this add-on your prompt will automatically refresh with the latest prompt every 100 milliseconds.
|
48
|
+
|
49
|
+
To change this you can configure this through your addon:
|
50
|
+
|
51
|
+
world.addons[:'prompt-refresh'].refresh_interval_in_ms = 150
|
52
|
+
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/zdennis/yap-shell-addon-prompt-refresh.
|
57
|
+
|
58
|
+
|
59
|
+
## License
|
60
|
+
|
61
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'yap/addon'
|
2
|
+
require 'yap-shell-addon-prompt-refresh/version'
|
3
|
+
|
4
|
+
module YapShellAddonPromptRefresh
|
5
|
+
class Addon < ::Yap::Addon::Base
|
6
|
+
self.export_as :'prompt-refresh'
|
7
|
+
|
8
|
+
DEFAULT_REFRESH_INTERVAL_IN_MS = 100
|
9
|
+
EVENT_NAME = 'addon:prompt-refresh'
|
10
|
+
|
11
|
+
attr_accessor :refresh_interval_in_ms
|
12
|
+
|
13
|
+
def initialize_world(world)
|
14
|
+
@world = world
|
15
|
+
self.refresh_interval_in_ms = DEFAULT_REFRESH_INTERVAL_IN_MS
|
16
|
+
|
17
|
+
@last_fired_at = nil
|
18
|
+
@world.subscribe EVENT_NAME do
|
19
|
+
fired_at = Time.now
|
20
|
+
|
21
|
+
message = "refreshing prompt"
|
22
|
+
message << " #{fired_at - @last_fired_at} seconds since last fired" if @last_fired_at
|
23
|
+
@last_fired_at = fired_at
|
24
|
+
|
25
|
+
logger.puts message
|
26
|
+
world.refresh_prompt
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def refresh_interval_in_ms=(milliseconds)
|
31
|
+
logger.puts "setting refresh interval to #{milliseconds.inspect} ms"
|
32
|
+
clear_recurring_event
|
33
|
+
if milliseconds
|
34
|
+
@refresh_interval_in_ms = milliseconds
|
35
|
+
initialize_recurring_event
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def clear_recurring_event
|
42
|
+
if @event_id
|
43
|
+
logger.puts "clearing previous refresh prompt event id=#{@event_id.inspect}"
|
44
|
+
@world.events.clear @event_id
|
45
|
+
@event_id = nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def initialize_recurring_event
|
50
|
+
logger.puts "initializing recurring event for event #{EVENT_NAME.inspect}"
|
51
|
+
@event_id = @world.events.recur \
|
52
|
+
name: EVENT_NAME,
|
53
|
+
interval_in_ms: refresh_interval_in_ms
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/lib/yap-shell-addon-prompt-refresh/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'yap-shell-addon-prompt-refresh'
|
5
|
+
spec.version = YapShellAddonPromptRefresh::VERSION
|
6
|
+
spec.authors = ['Your name']
|
7
|
+
spec.email = 'you@example.com'
|
8
|
+
spec.date = Date.today.to_s
|
9
|
+
|
10
|
+
spec.summary = 'prompt-refresh summary goes here.'
|
11
|
+
spec.description = 'prompt-refresh description goes here.'
|
12
|
+
spec.homepage = ''
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(/^(test\/|spec\/|features\/|.*\.gif$)/)
|
17
|
+
end
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(/^exe\//) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "yap-shell", "~> 0.7"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
25
|
+
spec.add_development_dependency "rake", "~> 11.2"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.5"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yap-shell-addon-prompt-refresh
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Your name
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: yap-shell
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '11.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '11.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.5'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.5'
|
69
|
+
description: prompt-refresh description goes here.
|
70
|
+
email: you@example.com
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files: []
|
74
|
+
files:
|
75
|
+
- ".gitignore"
|
76
|
+
- Gemfile
|
77
|
+
- LICENSE.txt
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
80
|
+
- lib/yap-shell-addon-prompt-refresh.rb
|
81
|
+
- lib/yap-shell-addon-prompt-refresh/version.rb
|
82
|
+
- yap-shell-addon-prompt-refresh.gemspec
|
83
|
+
homepage: ''
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.5.1
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: prompt-refresh summary goes here.
|
107
|
+
test_files: []
|
108
|
+
has_rdoc:
|