3.7 KiB
slosh
slosh is a new interactive shell designed for use at ssh [user]@colorfield.space
to replace the very limited shell that has been in use there for some time.
Q&A
Why a new shell?
It was a fun learning experience and I like tools I understand and can modify.
Why should I use slosh instead of other-shell
You shouldn't. slosh brings nearly nothing new to the table and was written to learn a bit more about how shells work, while improving on the current homemade shell for a hobby project/server. That said, some people might find it fun to hack on if they also want to play around with coding a shell.
What can it do?
slosh works more or less the way bash or sh work. Here is a list of what is currently implemented:
- Directory navigation w/ out the need for typing
cd
every time: just enter the path (including relative paths). Bothcd
anddir
are also available as commands that are aliased to this same behavior - Parsing and execution of commands, ie
ls -la
,cat ../aFolder/file1.txt ~/somefile.txt
, or the like - Pipes:
ls -la | lolcat
will work just fine, as will multiple pipes - Basic redirection:
ls -la | lolcat > myfile.txt
. You can append with>>
or create/overwrite with>
. At present bothStdout
andStderr
will be redirected - Continuation of command execution via
&&
, where execution will stop if a non-zero exit status is encountered - Command line history (accessible with the up and down arrows)
- Command and path completion with the tab key
- Command aliasing in the form of
alias [newname] [commands...]
- Variables with
set
andunset
in the formset [name] [value...]
andunset [name]
. At present, variables are only available at the environment level and not at the process level. Though process level variables are coming soon hopefully. - Parsing of
~/.slosh
, where you can alias or set and unset variables at runtime - Set your prompt by setting
$SLOSH_PROMPT
. Colors are not currently available due to a limitation in an underlying library. However, there is substitution available:%D
- The current working directory as a full path (/home/myname/.go/src/git.rawtext.club/sloum/slosh/
)%d
- The last three path segments of the current working directory (...git.rawtext.club/sloum/slosh/
)%c
- The current working directory (slosh
)%u
- The current active user (myname
), if there is an error retrieving the current user then???
will be printed- ...more coming soon
up
builtin command:up 3
is the equivalent ofcd ../../../
Will there be a full scripting language?
No. This is a simple shell to facilitate basic navigation of a filesystem and command execution. There are no current plans to bake in conditionals, functions, loops, etc.
Are there any other features that you plan to add?
At present there is no file globbing support. So that will likely get added soon. More complete redirection may also get added (sending stderr to /dev/null and writing stdout to a file or the like).
Building
Makefile coming soonTM. Until then, you can build locally like so (then move it to your path if you want):
git clone https://git.rawtext.club/sloum/slosh && cd slosh
go build -ldflags "-w -s" -o slosh
I recommend running upx -9 ./slosh
if you have upx
and want a smaller binary. But it will work fine either way, so not a big worry.
If you'd prefer to just run it once for fun:
git clone https://git.rawtext.club/sloum/slosh && cd slosh && go run *.go
License
slosh is released under the floodgap free software license, a copy of which is included in the repo.