Crates.io | vrsh |
lib.rs | vrsh |
version | 0.1.2 |
source | src |
created_at | 2021-05-30 08:27:33.53101 |
updated_at | 2023-05-28 19:33:29.994763 |
description | A simple shell written for my own learning. |
homepage | |
repository | |
max_upload_size | |
id | 403777 |
size | 603,054 |
A small shell written in rust as a way for me to learn rust
Long term goal/dream (not gonna happen), achieve POSIX compliance (https://pubs.opengroup.org/onlinepubs/009604499/utilities/xcu_chap02.html).
To customize the prompt, one can set the PROMPT
variable.
This can be done using the set var=val
syntax where val
is a string, please note that if single quotes ('
) are used for the string the content of the string is preserved and prompt expansions will be performed on the prompt, see prompt expansions.
If double quotes ("
) are used for the string, the standard expansions will be performed on the string (note that these are evaluated immediately whereas the single quote syntax is evaluated on each prompt display).
To make the prompt configuration permanent one can set the PROMPT
variable in the ~/.vrshrc
file (generated on application launch if it does not exist).
The following prompt expansions are currently supported:
%%
for the %
char.%n
username of the current user.%F{var}
to set the foreground color of the coming text, var must either be one of the supported colors (see prompt expansion colors);
or a number in the range 0-255, see ansi 8-bit coloring.%f
resets the foreground color.%K{var}
Works the same as %F
but for background color.%k
resets the background-color.%g
prints git information according to the built-in git module (used in the example below).%d
or %/
print the current working directory in full.%~
prints the current working directory but replaces /home/current_user
to ~/
.%~>
prints only the current directory with a leading /
(e.g. if the current path is /var/log
, this will print /log
). If the current working directory is /home/current_user
it will instead print ~/
.%-<
prints only the parent directories of the current directory (e.g. if in /var/log
this will print /var
). If the current directory is root (/
) nothing will be printed.To test colors in the current terminal, one can use the vrsh-colors
command which will print all 256 supported foreground and background colors.
The named colors and their numeric value are as follows:
red
= 1green
= 2orange
= 3blue
= 4purple
= 5bluegreen
= 6white
= 7gray
= 8darkred
= 9brightgreen
= 34brightblue
= 123pink
= 200yellow
= 220An example of the prompt that I myself currently use is the one below, it is somewhat verbose though.
set PROMPT='%F{blue} %~%f %F{orange} as %f %F{purple}%n%f %g %F{brightgreen} ❯ %f'
PROMPT
Gives the following prompt:
One can utilize the %~<
and %~>
options to print the full path but only highlight the current directory, for example:
set PROMPT='%F{31} %~<%f %F{51}%~>%f %F{214} as %f %F{170}%n%f %g %F{46} ❯ %f'
Gives the following prompt:
Example output from the vrsh-colors
command:
Currently only a small amount of features have been implemented but more are planned, feel free to suggest features to be added to the planned features list!
'
"asd""bsd"
should be one argument.$HOME
#
arrow-up
to go back in history and arrow-down
to go forward in history.$()
.|
.>
).<
).cd
exit
alias
~
-> the home directory of the current user.source
A="some value"
SOME_VARIABLE="some_value" firefox
tab
.&
&&