# Default file encoding to UTF-8 (no BOM) $OutputEncoding = [System.Text.UTF8Encoding]::new($false) [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false) # Prioritize Scoop shims $scoopShims = "$env:USERPROFILE\scoop\shims" if ($env:Path -notlike "$scoopShims*") { $env:Path = "$scoopShims;$env:Path" } #Install-Module -Name PSProfiler #Import-Module PSProfiler #Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1 $env:YAZI_FILE_ONE = 'C:\Program Files\Git\usr\bin\file.exe' $env:POSH_GIT_ENABLED = $false $env:POSH_THEME = "$env:POSH_THEMES_PATH\nordtron.omp.json" oh-my-posh --init --shell pwsh --config $env:POSH_THEME | Invoke-Expression Import-Module Terminal-Icons Import-Module DockerCompletion Import-Module CompletionPredictor Set-PSReadLineKeyHandler -Chord 'Ctrl+Spacebar' -Function MenuComplete #Set-PSReadLineKeyHandler -Key Tab -ScriptBlock { Invoke-FzfTabCompletion } Set-PSReadlineKeyHandler -Key Shift+Tab -Function TabCompletePrevious Set-PSReadlineKeyHandler -Key Ctrl+Tab -Function TabCompleteNext Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward # Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r' # Set-PsFzfOption -Invoke-FuzzyGitStatus # Set-PsFzfOption -TabExpansion Set-PSReadLineOption -PredictionSource History Set-PSReadLineOption -PredictionViewStyle ListView Set-PSReadlineOption -EditMode Vi Set-PSReadLineOption -ViModeIndicator Cursor function env { Get-ChildItem Env: | Format-Table -Wrap -AutoSize } function global:which ([string]$command) { if (-not($command)) { throw "ERROR: Please supply a command name" } (Get-Command $command).Path } # zoxide (cd enahncer) Invoke-Expression (& { $hook = if ($PSVersionTable.PSVersion.Major -lt 6) { 'prompt' } else { 'pwd' } (zoxide init --hook $hook --cmd z powershell | Out-String) }) # Compute file hashes - useful for checking successful downloads function md5 { (Get-FileHash -Algorithm MD5 $args).Hash.ToString() } function sha1 { (Get-FileHash -Algorithm SHA1 $args).Hash.ToString() } function sha256 { (Get-FileHash -Algorithm SHA256 $args).Hash.ToString() } function sha384 { (Get-FileHash -Algorithm SHA384 $args).Hash.ToString() } function sha512 { (Get-FileHash -Algorithm SHA512 $args).Hash.ToString() } function touch { $file = $args[0] if ($null -eq $file) { throw "No filename supplied"} if (Test-Path $file) { throw "File already exists" } else { # echo $null > $file New-Item -ItemType File -Name ($file) } } #vi function vi { &nvim $args } function tail { Param( [Parameter(Mandatory=$true)] [string]$Target ) Get-Content $Target -Tail 10 -Wait } function rmrf { Param( [Parameter(Mandatory=$true)] [string]$Target ) Remove-Item -Recurse -Force $Target } function adlookup_group { Param( [Parameter(Mandatory=$true)] [string]$Target ) Import-Module ActiveDirectory Get-ADGroupMember -Identity $Target | Select-Object Name | Format-Table @{ n='Name'; e='Name'; width = 200 } } function sshtunnel { Param( [Parameter(Mandatory=$true)] [string]$LocalPort, [Parameter(Mandatory=$true)] [string]$TargetMachine, [Parameter(Mandatory=$true)] [string]$TargetPort ) &"ssh" -N -T -4 jump -L ${LocalPort}:${TargetMachine}:${TargetPort} } function rdp { Param( [Parameter(Mandatory=$true)] [string]$Computer ) &"mstsc" /v:$Computer } function adlookup_user { Param( [Parameter(Mandatory=$true)] [string]$Target ) Import-Module ActiveDirectory (Get-ADUser $Target –Properties MemberOf).MemberOf | Get-ADGroup | Select-Object name | Format-Table @{ n='Name'; e='Name'; width = 200 } } function dmvn { Param( [Parameter(Mandatory=$true)] [string]$mvnArgs ) $mvnImage="3.9.6-eclipse-temurin-21" #$mvnImage="maven:3-openjdk-8-slim" $ws=$(wsl.exe wslpath -au .) $h="/mnt/c/users/reazul.ashraf/.m2" $command="docker run -t -d -u root:root --network host -v ${h}:/volume/.m2 -v /home/riz/.m2:/home/riz/.m2 -w ${ws} -v ${ws}:${ws}:rw,z $mvnImage cat" $id=(Invoke-Expression $command) docker exec -ti $id cp /home/riz/.m2/settings.xml /tmp/settings.xml docker exec -ti $id sed -i 's|.*<\/localRepository>|/volume/.m2/repository<\/localRepository>|g' /tmp/settings.xml docker exec -ti $id mvn -s /tmp/settings.xml $mvnArgs docker kill $id } Set-Alias -Name grep -Value rg Set-Alias -Name ls -Value eza Set-Alias -Name g -Value git Set-Alias -Name cat -Value bat Set-Alias -Name fork -Value 'C:\Users\reazul.ashraf\AppData\Local\Fork\Fork.exe' Set-Alias -Name winfetch -Value pwshfetch-test-1 Set-Alias -Name ocgv -Value Out-ConsoleGridView function vcvars { &'C:\Program Files\Microsoft Visual Studio\18\Community\Common7\Tools\Launch-VsDevShell.ps1' -SkipAutomaticLocation } function dep { $strArgs = $($args -split " ") &C:\devtools\dependencies\Dependencies.exe $strArgs } function ll { $strArgs = $($args -split " ") &eza -l $strArgs } function explore { if (!$args) { $path = '.' } else { $path=Convert-Path $args } &'C:\Program Files\GPSoftware\Directory Opus\dopus.exe' $path } function acl { if (!$args) { $path = '.' } else { $path=Convert-Path $args } &get-acl $path | format-table -wrap } function jdk8home { $env:JAVA_HOME="C:\Program Files\Eclipse Adoptium\jdk-8.0.482.8-hotspot" } function jdk8home32 { $env:JAVA_HOME="C:\Program Files (x86)\Eclipse Adoptium\jdk-8.0.472.8-hotspot" } function jdk21home { $env:JAVA_HOME="C:\Program Files\Eclipse Adoptium\jdk-21.0.10.7-hotspot" } function jdk25home { $env:JAVA_HOME="C:\Program Files\Eclipse Adoptium\jdk-25.0.2.10-hotspot" } function java { &$env:JAVA_HOME/bin/java.exe $args } function gemini { $env:NODE_OPTIONS="$env:NODE_OPTIONS --no-deprecation"; gemini.ps1} function sonarscan { pwsh -Command { jdk25home $branch = $(git branch --show-current) if ($null -eq $branch) { exit } $env:MAVEN_OPTS="-Dsonar.dependencyCheck.htmlReportPath=target/dependency-check-report.html -Dsonar.dependencyCheck.jsonReportPath=target/dependency-check-report.json -Dsonar.branch.name=$branch" mvn org.sonarsource.scanner.maven:sonar-maven-plugin:RELEASE:sonar -DskipTests -Drevision="$Env:USERNAME-$Env:COMPUTERNAME" New-BurntToastNotification -Text "Sonar Scan Complete", "Branch: $branch" } } function owaspdepcheck { pwsh -Command { jdk25home $env:MAVEN_OPTS="-Djdk.util.zip.disableZip64ExtraFieldValidation=true" mvn -B org.owasp:dependency-check-maven:RELEASE:aggregate -DskipTests -Dformats='XML,JSON,HTML' -DnvdApiKey=b00166ac-5422-402e-830c-998beba0265d New-BurntToastNotification -Text "OWASP Dependency Check Complete" } } # squash all commits into one function gsquash { &git reset --soft HEAD~$(git rev-list --count HEAD ^$args) } # Initialize a project for gemini-cli function ginit { &git init &git checkout -b gemini-cli Write-Host "Initialized git repository on 'gemini-cli' branch." -ForegroundColor Cyan } # set java home jdk25home $env:EDITOR = 'nvim' $env:VISUAL = 'nvim' $env:LESS = '-R -F -X' $env:BAT_PAGER = 'less -R -F -X' $env:DOCKER_HOST = "tcp://127.0.0.1:2375" $env:GEMINI_API_KEY = 'inse-r-and-d' # Added by Gemini CLI fnm env --use-on-cd | Out-String | Invoke-Expression