Skip to content

Commit

Permalink
Upgrade to nash v1
Browse files Browse the repository at this point in the history
  • Loading branch information
lucianobfaustino committed Jul 20, 2017
1 parent 6ad6f9d commit b939a69
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion examples/append.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env nash

example_list = ()
var example_list = ()
echo "appending string 1"
example_list <= append($example_list, "1")
echo $example_list
Expand Down
14 changes: 6 additions & 8 deletions examples/args.sh 100644 → 100755
@@ -1,13 +1,11 @@
#!/usr/bin/env nash

echo "iterating through the arguments list"
echo ""
print("iterating through the arguments list\n\n")
for arg in $ARGS {
echo $arg
print("%s\n", $arg)
}

echo ""
echo "acessing individual parameter"
somearg = $ARGS[0]
echo $somearg
echo ""
print("\n")
print("acessing individual parameter\n")
var somearg = $ARGS[0]
print("%s\n", $somearg)
30 changes: 16 additions & 14 deletions examples/init 100644 → 100755
@@ -1,47 +1,49 @@
#!/usr/bin/env nash

# Simple init script for you base your own
# For a more complete and organized .nash see:
# https://github.com/tiago4orion/dotnash

# PROMPT is a special variable used by nash command line to
# setup your prompt.
RED = "\033[31m"
GREEN = "\033[32m"
RESET = "\033[0m"

PROMPTSYM = "λ> "
DEFPROMPT = $RED + $PROMPTSYM + $RESET

PROMPT = $DEFPROMPT
var RED = ""
var GREEN = ""
var RESET = ""
var PROMPTSYM = "λ> "
var DEFPROMPT = $RED+$PROMPTSYM+$RESET

setenv PROMPT
setenv PROMPT = $DEFPROMPT

# cd overrides built-in cd
# Add the current branch before prompt (if current directory is a git repo)
fn cd(path) {
var branch = ""
var prompt = ""

if $path == "" {
path = $HOME
}

chdir($path)

-test -d ./.git
var _, status <= test -d ./.git

if $status != "0" {
PROMPT = $DEFPROMPT
prompt = $DEFPROMPT
} else {
branch <= git rev-parse --abbrev-ref HEAD | xargs echo -n
PROMPT = "(" + $GREEN + $branch + $RESET + ")" + $DEFPROMPT

prompt = "("+$GREEN+$branch+$RESET+")"+$DEFPROMPT
}

setenv PROMPT
setenv PROMPT = $prompt
}

bindfn cd cd

# syntax sugar to cd into go project
fn gocd(path) {
cd $GOPATH + "/src/" + $path
cd $GOPATH+"/src/"+$path
}

bindfn gocd gocd

0 comments on commit b939a69

Please sign in to comment.