Coder Social home page Coder Social logo

bcat's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bcat's Issues

bcat fails when the current directory contains spaces

bcat seems to fail when calling the browser with a path containing spaces.
For instance:
amon:50 Sources dom$ git log -p --color |bcat
The file /Users/foo/Documents/Personnel/21 Blog/50 Sources/Sources does not exist.

If you add quotes around the url when executing the comand it seems to work fine. I just changed line 49 of browser.rb from:

    exec "#{command} #{shell_quote(url)}"

to :

    exec "#{command} '#{shell_quote(url)}'"

I'm using the gem v. 0.5.0 but HEAD seems to have the same issue.

Hope this helps.

wring readme

AFAICT the second example in the README file should be

 echo .. | bcat -T "window title"

while it is

echo .. | bcat -t "window title"

which has the effect of trying to load an unexisting file (with an unpretty error)

Example Vim mapping doesn't work [with fix]

The first Vim mapping is:

:map ,pm :!markdown % |bcat

This didn't work for me. However this did:

:map ,pm :!markdown % \|bcat<CR>

You could also use <Bar> on the RHS instead of \|.

Shell quoting fails

The shell_quote method in browser.rb replaces any single-quotes (') with a backslash-escaped single-quote.

This doesn't actually work: there is no way to quote a single-quote inside a single-quoted string in a POSIX shell.

I opened another bug for the BCAT_COMMAND environment variable being ignored; it also includes a new shell_quote method that escapes single quotes correctly.

For example, shell_quote("foo'bar").inspect returns "'foo'"'"'bar'" which is correctly parsed by a POSIX shell.

Heres the function below:

    # return a given string quoted for a POSIX shell
    def shell_quote(argument)
      argument=argument.to_s
      # if the argument is a simple, single word, leave it alone
      if argument =~ /^[a-zA-Z0-9_+@%=,.\/\-]+$/
        argument
      else
        # replace any backslashes with escaped versions
        argument.gsub!(/(\\)/, "\\\\")
        # single quotes cannot be quoted inside single quotes, so we
        # end the single quoted string, put a double-quoted string containing a
        # single quote, and then start a new single-quoted string.  ugly, but works
        argument.gsub!(/'/, %w{'"'"'})
        # and wrap it in single quotes
        "'#{argument}'"
      end
    end

bcat isn't working for me

Sorry I can't be more precise. I'm on OS X 10.5.8, with Ruby 1.8.6. I installed it with 'sudo gem install bcat' and now I'm getting the following error whenever I attempt to run bcat, even just on its own:

  /Library/Ruby/Gems/1.8/gems/rack-1.2.1/lib/rack/utils.rb:138:in `union': can't convert Array into String (TypeError)
     from /Library/Ruby/Gems/1.8/gems/rack-1.2.1/lib/rack/utils.rb:138
     from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
     from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
     from /Library/Ruby/Gems/1.8/gems/bcat-0.5.0/lib/bcat/reader.rb:1
     from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
     from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
     from /Library/Ruby/Gems/1.8/gems/bcat-0.5.0/lib/bcat.rb:2
     from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
     from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
     from /Library/Ruby/Gems/1.8/gems/bcat-0.5.0/bin/bcat:49
     from /usr/bin/bcat:19:in `load'
     from /usr/bin/bcat:19

allow multiple connections

If at least btee can allow multiple connections, I can do things such as irb|btee and other people can watch what I do in btee.
That'd be awesome. :D

duplication on man page bcat-ing

for example (and quite appropriately) man echo | bcat

I get this:

It duplicates some of the headers, and the command. For completeness I included the man echo | cat.

license

Hi,

Could you create a LICENSE file containing your license ?
It's quite difficult to understand what license do you use.

Regards

Inject Css Styles

I'm wondering if it's possible to inject a css file, or control some of the html output through a command... I can try and work on it, not much of a ruby guy so would be a nice challenge :)

BCAT_COMMAND is ignored

% echo foo | env BCAT_COMMAND="echo >/dev/tty" bcat
[shows foo in my default browser as usual]

From browser.rb, it seems like the BCAT_COMMAND value is stored into @command, but @command isn't used.

Commenting out the "command = browser_command" so that the #{command} will call self.command works.

I've a patch below for this problem and the quoting problem (which I'll open a bug for after this):

--- /opt/local/lib/ruby/gems/1.8/gems/bcat-0.5.1/lib/bcat/browser.rb.original   2010-09-10 10:47:06.000000000 -0700
+++ /opt/local/lib/ruby/gems/1.8/gems/bcat-0.5.1/lib/bcat/browser.rb    2010-09-10 11:31:02.000000000 -0700
@@ -37,33 +37,39 @@
       'gnome'         => 'epiphany'
     }

-    def initialize(browser, command=ENV['BCAT_COMMAND'])
+    def initialize(browser, command=nil)
       @browser = browser
-      @command = command
+      @command = command || ENV['BCAT_COMMAND'] || command_for_browser(@browser)
     end

+    # open a given url
     def open(url)
-      command = browser_command
-      fork do
-        [$stdin, $stdout].each { |fd| fd.close }
-        exec "#{command} '#{shell_quote(url)}'"
-      end
-    end
-
-    def command
-      return @command if @command
-      browser_command
+      # run the browser command with stdin, stdout, and stderr closed
+      system "#{@command} </dev/null >/dev/null 2>&1 #{shell_quote(url)}"
     end

-    def browser_command(browser=@browser)
-      browser ||= 'default'
-      browser = browser.downcase
-      browser = ALIASES[browser] || browser
-      COMMANDS[ENVIRONMENT][browser]
+    # return the command to run for a given browser
+    def command_for_browser(browser='default')
+      browser = ALIASES[browser] || browser.downcase
+      COMMANDS[ENVIRONMENT][browser] || COMMANDS[ENVIRONMENT]['default']
     end

+    # return a given string quoted for a POSIX shell
     def shell_quote(argument)
-      arg = argument.to_s.gsub(/([\\'])/) { "\\" + $1 }
+      argument=argument.to_s
+      # if the argument is a simple, single word, leave it alone
+      if argument =~ /^[a-zA-Z0-9_+@%=,.\/\-]+$/
+        argument
+      else
+        # replace any backslashes with escaped versions
+        argument.gsub!(/(\\)/, "\\\\")
+        # single quotes cannot be quoted inside single quotes, so we
+        # end the single quoted string, put a double-quoted string containing a
+        # single quote, and then start a new single-quoted string.  ugly, but works
+        argument.gsub!(/'/, %w{'"'"'})
+        # and wrap it in single quotes
+        "'#{argument}'"
+      end
     end
   end
 end

ability to specify port

Related to #17: If I can specify the port, then i can use something like irb|btee --multiple --port=8000 (or w/e flag names you use) and people could connect on port 8000 to watch what i'm doing (AND I wouldn't need to adjust port forwarding every time, as I'd have to do now).

Contrib: a ZSH snippet (easily portable) to open man pages with bcat: bman

Hey Ryan,

I thought I'd share this little ZSH snippet for viewing man pages with formatting using bcat. It turns out this is actually quite tedious to achieve, because roff uses overprinting to achieve bold, rather than real ANSI bold escape sequences (a hangover from daisy-wheel printer days!).

function bman {
  colors
  local bold=$'\\(.\\)\b\\1'
  local ul=$'_\b\\(.\\)'
  man ${@} | sed "s/${bold}/$fg_bold[blue]\1$reset_color/g;s/${ul}/$fg_bold[red]\1$reset_color/g" | bcat
}

Hope this is useful to someone.

feature

First of all thank you for this great tool:
actually i use a2h and there is no spaces translation, convert spaces to &nbsp; ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.