Hosh is an experimental shell, featuring:
http
) and ifconfig clone (network
) as built-in commandshistory
command)HISTCONTROL=ignoredups
in bash)set -euo pipefail
(unofficial-strict-mode)text
, number
, path
, duration
and instant
| schema
to inspect available keystext
)withTime { lines very-big-file.txt | count }
like time command
in bashwithLock file.lock { command }
run command
as critical section guarded by file.lock
benchmark 10 { command }
run command
10 times and then report best/worst/average execution time¹ it is not intended to conform to IEEE POSIX P1003.2/ISO 9945.2 Shell and Tools standard
² much more design and work is needed in this area
Binary releases:
Requirements: JDK17+
$ java -jar hosh-0.2.0.jar
hosh> echo "hello world!"
hello world!
hosh>
Sorting is always performed using a well-defined key:
hosh> ls
# unsorted, following local file-system order
...
hosh> ls | schema
path size
hosh> ls | sort size
# files sorted by size
...
hosh> ls | sort path
# files sorted by alphanum algorithm
...
Walk is able to recursively walk a directory and its subdirectories, providing file name and size:
hosh> walk . | schema
path size
...
By sorting the output of walk
it is trivial to detect the biggest files:
hosh> walk . | sort size desc | take 5
aaa 2,5MB
bbb 1MB
ccc 1MB
ddd 1MB
eee 1MB
Stream line by line a TSV file via HTTPS, take first 10 lines, split each line by tab yielding a 1-indexed record and finally show a subset of keys.
Bash + wget + awk:
bash$ wget -q -O - -- https://git.io/v9MjZ | head -n 10 | awk -v OFS='\t' '{print $10, $1, $12}'
Hosh (no external commands):
hosh> http https://git.io/v9MjZ | take 10 | split text '\\t' | select 10 1 12
To recursively remove all .class
files in target
:
hosh> walk target/ | glob '*.class' | { path -> rm ${path}; echo removed ${path} }
{ path -> ... }
is lambda syntax, inside this scope is possible to use ${path}
.
It is possible to create records by using regex
built-in with capturing groups:
hosh> git config -l | schema
text
...
hosh> git config -l | regex text '(?<key>.+)=(?<value>.+)' | take 2
key value
credential.helper osxkeychain
user.name Davide Angelocola
hosh> hosh> git config -l | regex text '(?<key>.+)=(?<value>.+)' | take 2 | schema
key value
key value
And some nice UI features from: