forked from madlambda/nash
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ad6f9d
commit b939a69
Showing
3 changed files
with
23 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = "[31m" | ||
var GREEN = "[32m" | ||
var RESET = "[0m" | ||
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 |