Skip to content

Instantly share code, notes, and snippets.

@Kambaa
Last active February 16, 2026 11:08
Show Gist options
  • Select an option

  • Save Kambaa/db7bfcc3d8ce9f6a35e834479d25ae87 to your computer and use it in GitHub Desktop.

Select an option

Save Kambaa/db7bfcc3d8ce9f6a35e834479d25ae87 to your computer and use it in GitHub Desktop.
Windows powershell profile (like bashprofile) settings.
Clear-Host
# tab auto completion for git commands
# Install with:  PowerShellGet\Install-Module posh-git -Scope CurrentUser -Force
# more on website: https://github.com/dahlbyk/posh-git?tab=readme-ov-file#installation
Import-Module posh-git
oh-my-posh init pwsh | Invoke-Expression


function QuitReplacement{
Invoke-Command -ScriptBlock {exit}
}

New-Alias -Name q -Value QuitReplacement

$env:J17DIR = "C:\Users\kambaa\.jdks\corretto-17.0.12"
function j17 {
    $env:Path = "$env:J17DIR\bin;$env:Path"
    $env:JAVA_HOME = $env:J17DIR
    java --version
}


function OLDademo{
Set-Location -Path "C:\temp"
Remove-Item -Path .\* -Recurse -Force
mvn archetype:generate -DarchetypeGroupId='tr.com.mycompany' -DarchetypeArtifactId=my-archetype -DarchetypeVersion='v0.7.2'
$firstFolder = Get-ChildItem -Path "C:\temp" -Directory | Select-Object -First 1
if ($firstFolder ) {
    & 'idea' "$($firstFolder.Name)"
}
}

function ademo{
$root = 'C:\temp'

# check if C:\temp exist:
if (Test-Path -LiteralPath $root -PathType Container) {
    
    # temporarily go to $root
  	Push-Location -LiteralPath $root
	try {
	  # Remove EVERYTHING inside the folder (but not the folder itself)
      & Get-ChildItem -LiteralPath . -Force | Remove-Item -Recurse -Force
 	  # Run archtype generate
      & mvn archetype:generate -DarchetypeGroupId='tr.com.mycompany' -DarchetypeArtifactId=my-archetype -DarchetypeVersion='0.0.1-SNAPSHOT'
    }
	finally {
        Pop-Location
    }

	$firstFolder = Get-ChildItem -LiteralPath $root -Directory | Select-Object -First 1

	if ($firstFolder) {
        $folderPath = $firstFolder.FullName
        Push-Location -LiteralPath $folderPath
    	try {
        	  	# Run git in that folder
               	& git init
               	& git add .
                	& git commit -am "feat: inital"
     		# Open the folder in IntelliJ IDEA
            	& idea $folderPath
            }
            finally {
                Pop-Location
            }
        }
    }
}


function gpull {
    git pull origin (git rev-parse --abbrev-ref HEAD)
}

function gpush {
    git push origin (git rev-parse --abbrev-ref HEAD)
}




function mk{
	j17; ./mvnw spotless:apply; ./mvnw checkstyle:check
}


# eğer çalıştırılan dizinde maven wrapper varsa maven wrapper üzerinden
# komut çalıştırılsın, yoksa sistemde yüklü mvn komutu üzerinden devam edilsin.
function mvn {
    param(
        [Parameter(ValueFromRemainingArguments = $true)]
        [string[]]$MvnArgs
    )

    $env:JAVA_TOOL_OPTIONS='-Duser.language=en -Duser.country=US -Dfile.encoding=UTF-8'

    if (Test-Path "./mvnw") {
        Write-Host "Using wrapper ./mvnw"
        & ./mvnw @MvnArgs
    } else {
        Write-Host "Using system mvn from C:\dev\apps\maven\apache-maven-3.9.8\bin\mvn.cmd"
        & "C:\dev\apps\maven\apache-maven-3.9.8\bin\mvn.cmd" @MvnArgs
    }
}

 
function gradle{
    param (
        [Parameter(ValueFromRemainingArguments = $true)]
        [string[]] $GradleArgs
    )
 
    if (Test-Path "./gradlew") {
        Write-Host "Using wrapper ./gradlew"
        & ./gradlew @GradleArgs
    } else {
        Write-Host "Using system gradle from C:\dev\apps\gradle\bin\gradle.bat"
        & "C:\dev\apps\gradle\bin\gradle.bat" @GradleArgs
    }
}
 



# compose dosyalari farkli branch'lerde olunca, compose dosyasi olmadan ayaga kaldirdiklarimi silmek icin bu alias'i ayarladim.
function DockerStop {
    $allContainers = docker ps -a -q
    if ($allContainers) {
        docker stop $allContainers
        docker rm $allContainers
    }

    docker network prune -f
    docker volume prune -f
}

# bashrc'nin windows versiyonu ( $PROFILE editleme)
function profile {
	& "C:\Program Files\Sublime Text\sublime_text.exe" $PROFILE 
	#  notepad $PROFILE;
}

function time {
  param(
    [Parameter(ValueFromRemainingArguments = $true)]
    $Args
  )

  if (-not $Args -or $Args.Count -eq 0) {
    throw "Usage: time <command> [args...]"
  }

  $cmd  = $Args[0]
  $rest = @()
  if ($Args.Count -gt 1) { $rest = $Args[1..($Args.Count-1)] }

  $p = [System.Diagnostics.Process]::GetCurrentProcess()
  $cpuStart = $p.TotalProcessorTime

  $sw = [System.Diagnostics.Stopwatch]::StartNew()
  & $cmd @rest
  $exitCode = $LASTEXITCODE
  $sw.Stop()

  $cpuEnd = [System.Diagnostics.Process]::GetCurrentProcess().TotalProcessorTime
  $cpu = $cpuEnd - $cpuStart

  $user = [double]$cpu.TotalSeconds   # approximation in PowerShell (no clean split user/sys)
  $sys  = 0.0                         # not available portably here
  $real = [double]$sw.Elapsed.TotalSeconds

  "`nreal  {0:0.000}s`nuser  {1:0.000}s`nsys   {2:0.000}s" -f $real, $user, $sys | Write-Host
  return $exitCode
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment