From ArchWiki
Revision as of 17:53, 14 September 2016 by I4k (talk | contribs) (Created page with "Category:Command shells [ Nash] is a minimalist and yet powerful shell with focus on readability and security of scripts. It's inspired b...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Nash is a minimalist and yet powerful shell with focus on readability and security of scripts. It's inspired by Plan9 rc shell and brings to linux a similar approach to namespace creation. There's a nashfmt program to correctly format nash scripts in a readable manner (much like Golang gofmt program).


Install the nash-gitAUR package.

Initial configuration

Make sure that nash has been successfull installed issuing the command below in your current shell:

$ nash

If you got a lambda prompt, the everything is fine.

When first executed, nash will create a .nash directory in $HOME. Enter the command below to discover by yourself what is this directory:

λ> echo $NASHPATH

Put a file called init inside this directory to configure it.

Nash only has 2 special variables:

  • PROMPT variable stores the unicode string used for ... you know
  • IFS is a list containing the set of character delimiters used internally to split command output into lists.

Nash doesn't have a cd builtin, but a builtin function chdir. In nash you cannot create aliases by matching string to strings, but only binding function to command names. The init below creates a cd alias:

defPROMPT = "λ> "

fn cd(path) {
        if $path == "" {
                path = $HOME

        PROMPT = "("+$path+")"+$defPROMPT
        setenv PROMPT

# bind the "cd" function to "cd" command name
bindfn cd cd

After saving the init file, simple start a new shell and now you can use cd as if it were a builtin keyword.

git:(master)λ> nash
λ> cd
(/home/i4k)λ> cd /usr/local

For a more elaborated cd or other aliases implementation, see the project dotnash.

Organizing the init

Nash scripts can be modular, but there's no concept of package. You can use the import keyword to load other files inside the current script session. For an example, see dotnash init.

Configuring $PATH

Inside the init put the code below (edit for your needs):

path = (

PATH = ""

for p in $path {
        PATH = $PATH+":"+$p

setenv PATH

Making nash your default shell



The cli supports emacs and vi modes for common buffer editing. Default mode is emacs and you can change issuing:

λ> set mode vi

See also