rubsh 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Manifest CHANGED
@@ -1,5 +1,4 @@
1
1
  CHANGELOG
2
- Manifest
3
2
  README.rdoc
4
3
  Rakefile
5
4
  bin/rubsh
@@ -9,3 +8,4 @@ lib/prompt.rb
9
8
  lib/rub_readline.rb
10
9
  lib/rubsh.rb
11
10
  rubsh.gemspec
11
+ Manifest
@@ -0,0 +1,84 @@
1
+ = Rubsh
2
+
3
+ Rubsh was created to be a native shell for ruby users. A irb which can also be
4
+ used as a normal shell without the akwardness of some of the features of bash
5
+ and other shells, and with the power of ruby.
6
+
7
+ = Installation
8
+
9
+ sudo gem source -a http://gemcutter.org
10
+ sudo gem install rubsh
11
+
12
+ Run rubsh on the commandline. Type help for a quick overview of usage.
13
+
14
+ = Features
15
+
16
+ * readline support
17
+ * tab completion
18
+ * aliases
19
+ * commandline history
20
+
21
+ = Usage
22
+
23
+ == aliases
24
+
25
+ ralias aliases a command.
26
+
27
+ Example:
28
+ ralias 'ls ls -Gh'
29
+
30
+ Currently an alias will not be parsed to include other aliases. i.e.
31
+ doing <tt>ralias 'ls ls -Gh'</tt> followed by <tt>ralias 'll ls -l'</tt> will not get you 'ls -lGh'
32
+
33
+ == .rubsh/rc.rb
34
+
35
+ Define your own functions, aliases etc in the rc file. It's included to the environment.
36
+
37
+ == Shortcuts
38
+
39
+ While normal commands as 'ls' etc work transparantly, you can also do things like:
40
+
41
+ '*'.ls
42
+
43
+ shortcut for Dir.glob(...)
44
+
45
+ '*'.ls.du
46
+
47
+ Does du on all the results
48
+
49
+ It also takes arguments:
50
+
51
+ '*'.ls.du(:sh)
52
+
53
+ is equivalent to du -sh *
54
+
55
+ == Prompt
56
+
57
+ use ENV['PR1'] to set your prompt. see 'help prompt' for options from within the shell.
58
+
59
+ %h - hostname
60
+ %u - the username of the current user
61
+ %w - the current working directory, with $HOME abbreviated with a tilde
62
+ %W - the basename of the current working directory, with $HOME abbreviated
63
+ with a tilde
64
+ %Cb - blue color
65
+ %Cc - cyan color
66
+ %Cg - green color
67
+ %CC - color reset
68
+ %t - the current time in 24-hour HH:MM:SS format
69
+ %% - literal %
70
+ %$ - if the effective UID is 0, a #, otherwise a $
71
+
72
+ Example: ENV['PR1'] = "[%u@%h]--(%t)\n\r[%w]%$ "
73
+
74
+ == Commandline functions
75
+
76
+ Commandline functions must currently be defined as one-liners. They also take an argument, which
77
+ is what was typed to invoke the command.
78
+
79
+ def test(*a); p a;end
80
+ $ test foo #=> ["test foo"]
81
+
82
+
83
+
84
+
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'echoe'
3
- Echoe.new('rubsh','0.0.1') do |gem|
3
+ Echoe.new('rubsh','0.0.2') do |gem|
4
4
  gem.description = 'A ruby shell'
5
5
  gem.url = 'http://github.com/danielb2/rubsh'
6
6
  gem.author = 'Daniel Bretoi'
@@ -1,10 +1,35 @@
1
1
  require 'readline'
2
+ def get_local_dirs(str)
3
+ Dir[str+'*'].
4
+ grep( /^#{Regexp.escape(str)}/ ). #only return dirs which start with str
5
+ map { |f| f =~ /\s/ ? "\"#{f}\"" : f } # if names have spaces, then quote
6
+ end
7
+
8
+ # tab completion here is bad because we don't know if the str has a 'cd' before it.
9
+ # That makes us go through the executables as well when we're doing cd str[TAB]
10
+ def get_executables(str)
11
+ commands = []
12
+ ENV["PATH"].split(':').each do |dir|
13
+ Dir.glob("#{dir}/*").grep( /#{File::SEPARATOR}?#{Regexp.escape(str)}/ ).each do |file|
14
+ begin
15
+ stat = File.stat(file)
16
+ commands << File::basename(file) if stat.executable? and not stat.directory?
17
+ rescue
18
+ end
19
+ end
20
+ end
21
+ return commands
22
+ end
2
23
  Readline.completion_proc = Proc.new do |str|
3
- Dir[str+'*'].
4
- grep( /^#{Regexp.escape(str)}/ ). #only return dirs which start with str
5
- map { |f| f =~ /\s/ ? "\"#{f}\"" : f } # if names have spaces, then quote
6
- #Dir[str+'*'].select { |f| File.stat(f).executable? }.grep( /^#{Regexp.escape(str)}/ )
7
- # + commands_in_path.grep( /^#{Regexp.escape(str)}/ )
24
+ completions = get_local_dirs(str)
25
+
26
+ # if it's the first thing we're typing in, assume this to be a command and not just a dir.
27
+ # iow, we don't do this for second arg allowing executables not to be completed when
28
+ # prefixed by example 'cd'.
29
+ if Readline.line_buffer =~ /^\s*#{Regexp.escape(str)}/
30
+ completions += get_executables(str)
31
+ end
32
+ completions
8
33
  end
9
34
 
10
35
  def commands_in_path
@@ -2,29 +2,29 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rubsh}
5
- s.version = "0.0.1"
5
+ s.version = "0.0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Daniel Bretoi"]
9
- s.date = %q{2009-10-29}
9
+ s.date = %q{2010-10-09}
10
10
  s.default_executable = %q{rubsh}
11
11
  s.description = %q{A ruby shell}
12
12
  s.email = %q{daniel@netwalk.org}
13
13
  s.executables = ["rubsh"]
14
14
  s.extra_rdoc_files = ["CHANGELOG", "README.rdoc", "bin/rubsh", "lib/alias.rb", "lib/commands.rb", "lib/prompt.rb", "lib/rub_readline.rb", "lib/rubsh.rb"]
15
- s.files = ["CHANGELOG", "Manifest", "README.rdoc", "Rakefile", "bin/rubsh", "lib/alias.rb", "lib/commands.rb", "lib/prompt.rb", "lib/rub_readline.rb", "lib/rubsh.rb", "rubsh.gemspec"]
15
+ s.files = ["CHANGELOG", "README.rdoc", "Rakefile", "bin/rubsh", "lib/alias.rb", "lib/commands.rb", "lib/prompt.rb", "lib/rub_readline.rb", "lib/rubsh.rb", "rubsh.gemspec", "Manifest"]
16
16
  s.homepage = %q{http://github.com/danielb2/rubsh}
17
17
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rubsh", "--main", "README.rdoc"]
18
18
  s.require_paths = ["lib"]
19
19
  s.rubyforge_project = %q{rubsh}
20
- s.rubygems_version = %q{1.3.5}
20
+ s.rubygems_version = %q{1.3.7}
21
21
  s.summary = %q{A ruby shell}
22
22
 
23
23
  if s.respond_to? :specification_version then
24
24
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
25
  s.specification_version = 3
26
26
 
27
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
28
28
  else
29
29
  end
30
30
  else
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubsh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
5
10
  platform: ruby
6
11
  authors:
7
12
  - Daniel Bretoi
@@ -9,7 +14,7 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-10-29 00:00:00 -07:00
17
+ date: 2010-10-09 00:00:00 -07:00
13
18
  default_executable:
14
19
  dependencies: []
15
20
 
@@ -30,7 +35,6 @@ extra_rdoc_files:
30
35
  - lib/rubsh.rb
31
36
  files:
32
37
  - CHANGELOG
33
- - Manifest
34
38
  - README.rdoc
35
39
  - Rakefile
36
40
  - bin/rubsh
@@ -40,6 +44,7 @@ files:
40
44
  - lib/rub_readline.rb
41
45
  - lib/rubsh.rb
42
46
  - rubsh.gemspec
47
+ - Manifest
43
48
  has_rdoc: true
44
49
  homepage: http://github.com/danielb2/rubsh
45
50
  licenses: []
@@ -55,21 +60,26 @@ rdoc_options:
55
60
  require_paths:
56
61
  - lib
57
62
  required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
58
64
  requirements:
59
65
  - - ">="
60
66
  - !ruby/object:Gem::Version
67
+ segments:
68
+ - 0
61
69
  version: "0"
62
- version:
63
70
  required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
64
72
  requirements:
65
73
  - - ">="
66
74
  - !ruby/object:Gem::Version
75
+ segments:
76
+ - 1
77
+ - 2
67
78
  version: "1.2"
68
- version:
69
79
  requirements: []
70
80
 
71
81
  rubyforge_project: rubsh
72
- rubygems_version: 1.3.5
82
+ rubygems_version: 1.3.7
73
83
  signing_key:
74
84
  specification_version: 3
75
85
  summary: A ruby shell