Skip to content
/ pageboy Public

Write your shell scripts in any combination of scripting languages.

Notifications You must be signed in to change notification settings

khtdr/pageboy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pageboy

Write your shell scripts in any combination of scripting languages.

installation

  1. Current version: 2.1.4
  2. Download the pageboy bash script and put into your $PATH (ie. ~/bin/).
  3. Start using #!/usr/bin/env pageboy as your shebang line in your bash scripts.
  4. Call other "pages" of your script by using the pre-defined $PAGE command in your scripts.
curl -o ~/bin/pageboy https://raw.githubusercontent.com/khtdr/pageboy/master/pageboy; chmod +x ~/bin/pageboy

Verify the install

~/bin/pageboy -h

Example Script example.pb

#!/usr/bin/env pageboy
echo in Bash
$PAGE php
echo back to Bash

#!/usr/bin/env php
<?php echo "in PHP\n";
chmod +x ./example.pb
./example.pb

produces the output:

in Bash
in PHP
back to Bash

tests

Build Status

./run-tests.sh
Running test suite for: pageboy-v2.1.4
./tests/aliased.pb ... passed
./tests/args.pb ... passed
./tests/awk.pb ... passed
./tests/big.pb ... passed
./tests/confusing.pb ... passed
./tests/dump.pb ... passed
./tests/env-export.pb ... passed
./tests/lots.pb ... passed
./tests/named.pb ... passed
./tests/page.pb ... passed
./tests/pageboy.pb ... passed
./tests/paths.pb ... passed
./tests/plain-bash.pb ... passed
./tests/print-php.pb ... passed
./tests/pwd.pb ... passed
./tests/run-php.pb ... passed
./tests/subshell-args.pb ... passed
./tests/version.pb ... passed
./tests/weird "name$".pb ... passed

You can mix and match all you want. If your script uses valid shebangs, it will work. If it doesn't, it's a bug and please let me know. It also supports the (not quite right) awk shebang: #!/usr/bin/env awk.

quickstart examples

#!/usr/bin/env pageboy
$PAGE php | wc

#!/usr/bin/env php
<?php
phpinfo();

produces:

 934    3524   29671

If you want multiple pages of the same language, append an index, starting at 1, to the pagename.

#!/usr/bin/env pageboy
cat <($PAGE php1) <($PAGE php2)

#!/usr/bin/env php
<?php echo "one";

#!/usr/bin/env php
<?php echo "two";

produces:

onetwo

You can distribute a version of your script without the dependency on pageboy by compiling it:

# copy above into `onetwo.pb`
onetwo.pb -c > onetwo.sh
chmod +x ./onetwo.sh
./onetwo.sh

produces:

onetwo

Big Example

#!/usr/bin/env pageboy
cat <($PAGE php) <($PAGE ruby) <($PAGE bash1) <($PAGE bash2) <($PAGE php2)

#!/usr/bin/env php
<?php
for ($i=10; $i<=20; $i++) {
  echo $i . "\n";
}

#!/usr/bin/env ruby
5.times do
  puts "Hello, World! ~ruby1"
end

#!/bin/bash
echo "Hello, World! ~bash2"
whoami

#!/usr/bin/env bash
env | grep TERM

#!/usr/bin/env php
<?php
echo __DIR__;

produces:

10
11
12
13
14
15
16
17
18
19
20
Hello, World! ~ruby1
Hello, World! ~ruby1
Hello, World! ~ruby1
Hello, World! ~ruby1
Hello, World! ~ruby1
Hello, World! ~bash2
khtdr
TERM_PROGRAM=iTerm.app
TERM=xterm-256color
ITERM_PROFILE=Default
ITERM_SESSION_ID=w0t0p0
/home/khtdr/

feature guide

pageboy -h
pageboy-v2.1.4
    pageboy            # runs as pageboy script
    pageboy -r <page>  # runs requested page
    pageboy -p <page>  # prints requested page
    pageboy -c         # compiles to bash script
    pageboy -d         # dumps page table
    pageboy -h         # shows this message
https://github.com/khtdr/pageboy

More examples can be found in the tests directory.

advanced features

About

Write your shell scripts in any combination of scripting languages.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published