This project was a joint project - Credits to @Leo @RoryBrownie @SkeneLord
An exercise in finding out that bash was way more extensive than we first thought.
- External program support
- Shell script support
- A bunch of builtins
- Redirection
- Profile loading
- Custom PS1
- History
- Cycling through previous commands (up/down arrows)
also we implemented our own readline! 👍
Profiles are shell scripts that are ran on launch of Bashanelli.
Bashanelli will attempt to load standard bash and sh profiles (~/.profile
, ~/.bash_profile
, etc) upon launch.
Currently disabled as Bashanelli cannot handle conditions and loops, which bash profiles are full of.
Bashanelli loads its own profile on launch.
This is loaded from ~/.bnli_profile
, if such a file exists.
Bashanelli parses its PS1 (prompt) string from the $PS1
environment variable.
In order to set a custom PS1 you can add the following line to ~/.bnli_profile
:
export PS1=<custom PS1>
Note that control characters must be double escaped as the slashes are escaped while parsing the export
statement, as well as when parsing the PS1.
\\h
- Hostname, up to the first appearance of.
\\H
- Hostname\\u
- Login\\s
- The name of the shell (Usually "bashanelli")\\w
- The current working directory\\n
- Newline char (\n
)
ANSI escape codes can be used (for colour and formatting).
They must be written in the following form:
"\\033[<ANSI code>m"
export PS1="\\033[1m\\033[32m\\u@\\h\\033[0m:\\033[1m\\033[34m\\w\\033[0m\\033[1m> \\033[0m"
With a user "bob" on a machine "myComputer", the PS1 will look as follows:
Bashanelli uses a bash-style history that keeps track of previously entered commands.
The history is stored in ~/.bnli_history
.
!!
- Execute last command.!<n>
- Executes the nth command from the history.!<-n>
- Executes the nth last command from the history.
Changes the working directory. Providing no args changes the working directory to $HOME.
Prints each line in the history along with its assosciated number.
-c
/--clear
- Clears the history.
Sets an environment variable to a given value.
-p
- Prints all environment variables.
Unsets the value of a given environment variable.
Assigns an alias to a given command.
-p
- Prints all aliases.
Removes a given alias.
-a
- Removes all aliases.
Executes a given command as a builtin.
Executes a given command as a shell script.
Executes a given command as an executable program.
Quits the shell with exit code 0.