Life lessons

There are some life lessons which I learned with experience.

  • If you want to do some good work, then you need to invest for that. Investment can be in terms of money, energy or time (or all of those).
  • Everything has a life time, after that it will go away. As an example, the skills which you have currently, will expire someday and become outdated.
  • The important thing is the ‘journey’ not the ‘destination’.

PowerShell in a container

Recently I found that we can execute a PowerShell script in a docker container. There is a base image for PowerShell in docker hub and you can use that to create your own image with your PowerShell script. Now when you create docker image and container from that, your PowerShell script can execute inside that container.

Example: https://github.com/Arnab-Developer/PowerShellInContainer

Custom PowerShell prompt

My custom PowerShell prompt without the use of oh-my-posh. Create or open file with name Microsoft.PowerShell_profile.ps1 at location C:\Users\<your user name>\Documents\PowerShell\ and paste this code inside that. Then open a PowerShell window to check the prompt.

function prompt
{
    [string] $currentFolderName = GetCurrentFolderName
    [string] $gitStatus = (git status)
    if ([string]::IsNullOrEmpty($gitStatus))
    {
        Write-Host "→ $currentFolderName" -NoNewLine -ForegroundColor DarkCyan
    }
    else
    {
        Write-Host "→ $currentFolderName (" -NoNewLine -ForegroundColor DarkCyan
        Write-Host "$(git branch --show-current)" -NoNewLine -ForegroundColor DarkRed
        Write-Host ")" -NoNewLine -ForegroundColor DarkCyan
    }
    return " "
}

function GetCurrentFolderName
{
    [string] $location = Get-Location
    [string] $currentFolderName = [string]::Empty
    if ($location.EndsWith("\"))
    {
        $currentFolderName = $location
    }
    else
    {
        [int] $lastIndexOfSlash = $location.LastIndexOf("\")
        $currentFolderName = $location.SubString($lastIndexOfSlash + 1)
    }
    return $currentFolderName
}