alias

A Powershell alias for outputting info from functions

In most common programming languages, a function (or method) defines a block of code that does some work internally, and returns a value at the end, either implicitly (the result of processing the last line is returned), or explicitly (a keyword such as return is used to specify the return-value). In Powershell on the other hand, everything is returned out. Take the following example for instance:

function get-an-array {
    "Creating an array..."
    $arr = "one","two","three"
    "Array created; returning it now:"
    return $arr 
}

#calling the function:
$myArray = get-an-array

In most languages, you would expect $myArray to contain just that – an array after executing the code above. Also, you might have expected the messages in between to have been written out to the screen. Not so! The actual content of the resulting variable will be as follows:

Continue reading

GIT alias: List all branches

Using GIT? Quick tip of the day: Add the line below to the  [alias] section of your .gitconfig file (you should find it in your home directory). This will let you quickly list all the branches available for a repo.

brl = branch --list --all

Save the file, and try the following command in a GIT window:

git brl

You should see a list of all available branches for the repo, both remote and local, with an asterisk marking the branch you currently have checked out:

A Git alias for logs, Version 2.0

A while back, I wrote a post about how to improve the log command in git by adding a customized alias for it. I’ve been fairly happy with that alias, but I kept missing one thing: A date, or some similar indicator of the age of each commit. Today, I finally set aside time to improve it, and here`s the result:

lg = log --format=\"%h: %Cgreen%an %ar %Creset(%ci) %n         %s\" -10

Continue reading