Introducing Yap

 

Part I: My beta's beta

 

Yap is a shell...

Shell

(REPL, TTY, Process, Job Control, History, Line Editing)

Language (Grammar/Lexer/Parser)

Interpretor

(AST Evaluation Execution)

Execution

(Aliases|User-defined|Builtins|Executables)

...a developer shell.

Non-blocking REPL

Addons

World

Event-based

Minimal Core

Concurrency (Simulated, Thread)

Rendering

2 slides to explain why.

(1 of 2)

 

?

(2 of 2)

Why?

Can't I have a right prompt?

 

Must I remember time?

 

Language reference for simple things?

 

Am I writing in a shell scripting language?

 

Can't my prompt live update?

Why?

Can't my shell push information to me?

 

Can't I share my tidbits with others?

 

Can't I discover others tidbits?

 

Does everyone seem to copy/paste or use that one guy's . files?

 

Why can't I inline exec Ruby?

Existing shells?

“You can please some of the people all of the time,
you can please all of the people some of the time,
but you can’t please all of the people all of the time.”

Yap is my nighttime drive with shabby head lights.

Scripting language

nope

Text

Yap has a shell language, not a scripting language. It has Ruby.

Scripting language

nope

Text

#!/bin/sh

Shell language

the familiar bits

Shell language:commands
yap> ls
yap> ls -a path/to/program
yap> ./a_program
Shell language: pipes
yap> cat foo.txt | grep -v bar | sort
Shell language: conditionals
yap> script/pass && script/do_something_else
yap> script/fail || script/do_not_do_this
Shell language: grouping
yap> (prog1 && (prog2 || prog3))
Shell language: redirection
# STDIN
yap> script/howdy < foo.txt

# STDOUT
yap> echo foo > foo.txt
yap> echo bar 1> bar.txt


#STDERR
yap> script/wazzup 2> errors.txt


# STDOUT and STDERR (different places)
yap> script/wazzup 1> output.txt 2> errors.txt


# NOT YET IMPLEMENTED
yap> script/wazzup 2>&1 output.txt
yap> echo baz >> baz.txt
Shell language: env vars
# Current shell, passed to programs, no exporting
yap> FOO=foo
yap> echo $FOO
foo

# Current statement 
yap> FOO=bar echo $FOO ; echo $FOO
bar
foo

# doesn't have to be upper case
yap> a=b b=c
yap> echo $a $b
b c

Shell language: expansions
# variable expansion
yap> echo $FOO

# tilde expansion
yap> cd ~/

# word expansion
yap> echo a_{1,2,3,4}
a_1 a_2 a_3 a_4

# alias expansion
yap> alias ls='ls -G'
yap> alias rbfiles="ls *.rb"
yap> rbfiles





Shell language: tab completion
# when searching commands
#   - builtins
#   - user-defined functions
#   - aliases
#   - executables found in $PATH
#   - environment variables if leading $
yap> some_[tab]



# when searching arguments
#   - files in pwd
#   - directories in pwd
#   - environment variables if leading $
yap> some_program [tab]





Shell language: multiline input
# unterminated quotes request additional input
# while keeping new lines intact
yap> echo "this is
> not done
> yet
> ok, done."
this is
not done
yet
ok, done.

# backslash indicates to treat multiple lines
# as a single line of input, no newlines
yap> echo this is \
> a great \
> day.
this is a great day.





Shell language: basic job scheduling
yap> ./infinite-script-printing-a-dot-a-second
..............
[Ctrl-Z]
yap> fg

Shell language

not yet familiar
Shell language: repetition
# the simple form
yap> 2.times: echo foo
foo
foo


# the whole statement
yap> 2.times: echo foo ; echo baz
foo
baz
foo
baz

# parameterized
yap> 2.times as n: echo $n
1
2

# shadowing
yap> n=blargy
yap> 1.times as n: echo $n
1
yap> echo $n
blargy
Shell language: repetition w/blocks
# the simple form
yap> 2.times { echo foo } ; echo done
foo
foo
done


# parameterized
yap> 2.times { |n| echo $n } ; echo done
1
2
done

# shadowing
yap> n=blargy
yap> 1.times { |n| echo $n }
1
yap> echo $n
blargy
Shell language: blocks
# can come after any command
yap> ls *.rb {|f| echo $f }
file1.rb
file2.rb
file3.rb


# can be used to step thru
yap> ls *.rb {|f,g| echo $f $g }
file1.rb file2.rb
file3.rb
Shell language: ranges
# just like ruby ranges, but no triple-dot non-inclusive range :(
yap> (0..1): echo foo
foo
foo

# parameterized
yap> (0..1) as n: echo $n
0
1

# w/block
yap> (0..1) { echo hi }
hi
hi

# w/block parameters
yap> (0..1) { |n| echo $n }
0
1

# w/block parameters
yap> (0..2) { |n, o| echo $n $o }
0 1
2

Let's talk about fun stuff

Right Prompt

 add-on

>1 tabs, =1 Branch

add-on

Sharing, Discovery

planned

Homebrew-inspired Tooling

Package Manager

(Maybe piggy back on Rubygems)

Inline ruby code

integrated

Text

rcfiles

integrated

Text

[this is a reminder to go take a peek]

interesting bits

terminal-layout: minimal browser rendering engine

Treefell: debug logging utility

ANSIString: ANSI-sequence aware string implementation

# Want to play around? 
# (Yes rbenv, probably chruby, but no RVM)
gem install yap-shell


# Github
http://github.com/zdennis/yap-shell


# Ideas / Issues
http://github.com/zdennis/yap-shell/issues


# Docs will be up soon!
http://github.com/zdennis/yap-shell/wiki



Made with Slides.com