Skip to content

Instantly share code, notes, and snippets.

@AlbertoDePena
Last active October 12, 2020 15:05
Show Gist options
  • Save AlbertoDePena/3823ec6cc8b493de5239209690867561 to your computer and use it in GitHub Desktop.
Save AlbertoDePena/3823ec6cc8b493de5239209690867561 to your computer and use it in GitHub Desktop.
function prompt {
Write-Host("")
$statusString = ""
$symbolicRef = git symbolic-ref HEAD
$isGit = $NULL -ne $symbolicRef
$location = $(get-location)
if ($isGit) {
$branch = $symbolicRef.substring($symbolicRef.IndexOf("heads/") + 6)
$statusString = "GIT " + $branch + " " + $location + ">"
}
else {
$statusString = "PS " + $location + ">"
}
if ($isGit) {
Write-Host ($statusString) -nonewline -foregroundcolor magenta
}
else {
Write-Host ($statusString) -nonewline -foregroundcolor green
}
return " "
}
function Remove-Node-Modules {
echo "Deleting node_module directory..."; ls node_modules -Recurse -Directory | foreach { rm $_ -Recurse -Force }
}
function touch {
Param(
[Parameter(Mandatory=$true)]
[string]$Path
)
if (Test-Path -LiteralPath $Path) {
(Get-Item -Path $Path).LastWriteTime = Get-Date
} else {
New-Item -Type File -Path $Path
}
}
function Base64Encode {
Param(
[Parameter(Mandatory=$true)]
[string]$RawText
)
$bytes = [System.Text.Encoding]::UTF8.GetBytes($RawText)
$encoded = [System.Convert]::ToBase64String($bytes)
echo $encoded
}
function Base64Decode {
Param(
[Parameter(Mandatory=$true)]
[string]$EncodedText
)
$bytes = [System.Convert]::FromBase64String($EncodedText)
$decoded = [System.Text.Encoding]::UTF8.GetString($bytes)
echo $decoded
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment