-
Notifications
You must be signed in to change notification settings - Fork 0
/
_profile.tiny
66 lines (56 loc) · 1.85 KB
/
_profile.tiny
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
####################################################################
#
# Code automatically loaded when tiny is started.
#
####################################################################
#
# Launch the tiny editor on a file.
#
fn TEdit filename -> run('editor', filename);
#
# Copy the contents of the file to the screen
fn cat fileToCat -> readfile(fileToCat) |> printlist;
# Utility to print out files, multiple per line
fn wls pattern='*.tiny' perRow=3 width=25 ->
((ls(pattern)*.name) / perRow)
|> foreach {
it.foreach { print( it.PadRight(width) ) };
println()
};
edit = GetCommand 'gvim';
gvim = GetCommand 'gvim';
#
# Utility to find a type amongst the loaded types.
#
fn FindType pattern ->
[<appdomain>]
.currentDomain
.getassemblies()
*.gettypes()
.flatten()
.aslist()
*.fullname
.matchall(pattern);
#
# This code works but it's much slower than calling
# Select-String
#
#fn grep pattern files = "*.tiny" {
# ls(files)
# |> readfile(pattern) {
# println( "{0}:{1} {2}",
# filename.path, it2, it)
# }
#}
#>
SelectString = GetCommand 'Select-String'
fn Grep pattern, file = '*.tiny' {
selectString(pattern, file)
}
#
# A 'ternary operator' for Tiny
fn ifElse val lambda1 -> if (val) {lambda1()} else {body()}
#
# List all of the tiny files
fn ltf -> [<tinylist>].Partition(ls("*.tiny").map{it.name}, 7).map{it |> map{format("{0,25}", it)} |> join()}
fn sls -> (ls("*.tiny").map{it.name} / 7) |> map { it.map{ format("{0,25}", it) } |> join("") |> println }