Skip to content

Instantly share code, notes, and snippets.

@zyryc
Created October 18, 2025 09:30
Show Gist options
  • Select an option

  • Save zyryc/70dbc8138a6c9ec838465c537d80cbbc to your computer and use it in GitHub Desktop.

Select an option

Save zyryc/70dbc8138a6c9ec838465c537d80cbbc to your computer and use it in GitHub Desktop.
Bash Profile
# ============================================
# PowerShell Profile - Colorful & Informative
# ============================================
# --- INSTALL THESE ONCE (if not already) ---
# Install-Module -Name Terminal-Icons -Repository PSGallery -Force
# Install-Module -Name PSReadLine -Force -SkipPublisherCheck
# winget install JanDeDobbeleer.OhMyPosh -s winget
# =============================
# 1️⃣ IMPORT MODULES
# =============================
Import-Module Terminal-Icons
Import-Module PSReadLine
# =============================
# 2️⃣ PSREADLINE CONFIGURATION
# =============================
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -EditMode Windows
Set-PSReadLineOption -BellStyle None
# Keybindings
Set-PSReadLineKeyHandler -Chord 'Ctrl+d' -Function DeleteChar
Set-PSReadLineKeyHandler -Chord 'Ctrl+w' -Function BackwardDeleteWord
Set-PSReadLineKeyHandler -Chord 'Alt+d' -Function DeleteWord
Set-PSReadLineKeyHandler -Chord 'Ctrl+LeftArrow' -Function BackwardWord
Set-PSReadLineKeyHandler -Chord 'Ctrl+RightArrow' -Function ForwardWord
Set-PSReadLineKeyHandler -Chord 'Ctrl+z' -Function Undo
Set-PSReadLineKeyHandler -Chord 'Ctrl+y' -Function Redo
# Colors
Set-PSReadLineOption -Colors @{
Command = 'Cyan'
Parameter = 'Gray'
Operator = 'Magenta'
Variable = 'Green'
String = 'Yellow'
Number = 'Blue'
Type = 'DarkCyan'
Comment = 'DarkGreen'
}
# =============================
# 3️⃣ OH MY POSH CONFIG
# =============================
if (Get-Command oh-my-posh -ErrorAction SilentlyContinue) {
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\tokyo.omp.json" | Invoke-Expression
} else {
Write-Host "⚠️ Oh My Posh not found. Install with: winget install JanDeDobbeleer.OhMyPosh" -ForegroundColor Yellow
}
# Alternative themes (uncomment one to try)
# oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\catppuccin_mocha.omp.json" | Invoke-Expression
# oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\space.omp.json" | Invoke-Expression
# oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\dracula.omp.json" | Invoke-Expression
# oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\capr4n.omp.json" | Invoke-Expression
# =============================
# 4️⃣ ALIASES
# =============================
Set-Alias -Name g -Value git
Set-Alias -Name lg -Value lazygit
Set-Alias -Name vim -Value nvim -ErrorAction SilentlyContinue
Set-Alias -Name ll -Value Get-ChildItemPretty
Set-Alias -Name grep -Value Select-String
Set-Alias -Name touch -Value New-Item
# =============================
# 5️⃣ CUSTOM FUNCTIONS
# =============================
function Get-ChildItemPretty {
Get-ChildItem | Format-Table -AutoSize
}
function whereis ($command) {
Get-Command -Name $command -ErrorAction SilentlyContinue |
Select-Object -ExpandProperty Path -ErrorAction SilentlyContinue
}
function mkcd ($dir) {
New-Item -ItemType Directory -Path $dir -Force | Out-Null
Set-Location $dir
}
function Update-Profile {
& $PROFILE
}
function Get-PublicIP {
(Invoke-WebRequest -Uri "https://api.ipify.org").Content
}
# --- Git shortcuts ---
function gs { git status }
function ga { git add $args }
function gc { git commit -m $args }
function gp { git push }
function gl { git log --oneline --graph --decorate --all }
function gd { git diff $args }
# --- LazyG: Quick add, commit & push ---
function lazyg {
param(
[Parameter(Mandatory=$true)]
[string]$message
)
Write-Host "🚀 LazyG: Starting quick commit..." -ForegroundColor Cyan
Write-Host ""
Write-Host "📦 Adding all changes..." -ForegroundColor Yellow
git add .
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ Failed to add files" -ForegroundColor Red
return
}
Write-Host "💾 Committing with message: " -ForegroundColor Green -NoNewline
Write-Host "`"$message`"" -ForegroundColor White
git commit -m "$message"
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ Failed to commit" -ForegroundColor Red
return
}
Write-Host "🌐 Pushing to remote..." -ForegroundColor Magenta
git push
if ($LASTEXITCODE -eq 0) {
Write-Host ""
Write-Host "✅ LazyG: All done! 🎉" -ForegroundColor Green
} else {
Write-Host "❌ Failed to push" -ForegroundColor Red
}
}
# =============================
# 6️⃣ WELCOME MESSAGE FUNCTION
# =============================
function Show-WelcomeMessage {
$os = Get-CimInstance -ClassName Win32_OperatingSystem
$cpu = Get-CimInstance -ClassName Win32_Processor | Select-Object -First 1
Write-Host ""
Write-Host " ╔═══════════════════════════════════════╗" -ForegroundColor Cyan
Write-Host " ║ " -ForegroundColor Cyan -NoNewline
Write-Host "PowerShell Terminal Loaded" -ForegroundColor Magenta -NoNewline
Write-Host " ║" -ForegroundColor Cyan
Write-Host " ╚═══════════════════════════════════════╝" -ForegroundColor Cyan
Write-Host ""
Write-Host " 💻 System: " -ForegroundColor Yellow -NoNewline
Write-Host $os.Caption -ForegroundColor White
Write-Host " 🎯 User: " -ForegroundColor Green -NoNewline
Write-Host $env:USERNAME -ForegroundColor White
Write-Host " 📁 Location: " -ForegroundColor Blue -NoNewline
Write-Host $PWD -ForegroundColor White
Write-Host ""
Write-Host " ⚡ Quick Commands:" -ForegroundColor Cyan
Write-Host " lazyg `"message`"" -ForegroundColor Yellow -NoNewline
Write-Host " - Add, Commit & Push" -ForegroundColor Gray
Write-Host " lg" -ForegroundColor Yellow -NoNewline
Write-Host " - Launch LazyGit" -ForegroundColor Gray
Write-Host " gs" -ForegroundColor Yellow -NoNewline
Write-Host " - Git Status" -ForegroundColor Gray
Write-Host " ll" -ForegroundColor Yellow -NoNewline
Write-Host " - List Files (Pretty)" -ForegroundColor Gray
Write-Host ""
}
# =============================
# 7️⃣ RUN WELCOME MESSAGE
# =============================
# Use try-catch to handle any errors gracefully
try {
Show-WelcomeMessage
} catch {
Write-Host "Welcome to PowerShell! ⚡" -ForegroundColor Cyan
}
# =============================
# 8️⃣ OPTIONAL STARSHIP PROMPT
# =============================
# Invoke-Expression (&starship init powershell)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment