refactor: convert to Unix style

This commit is contained in:
m1ngsama 2025-11-25 16:00:00 +08:00
parent dc541fd3a3
commit f43a77922b
7 changed files with 114 additions and 118 deletions

178
README.md
View file

@ -1,19 +1,19 @@
# winfig # winfig
> Comprehensive Windows development environment configuration toolkit Comprehensive Windows development environment configuration toolkit
Winfig is a curated collection of configurations, scripts, and utilities designed to transform your Windows terminal into a powerful, efficient development environment. Optimized for Windows Terminal, PowerShell, and modern development workflows. Winfig is a curated collection of configurations, scripts, and utilities designed to transform your Windows terminal into a powerful, efficient development environment. Optimized for Windows Terminal, PowerShell, and modern development workflows.
## Features ## Features
- ** Performance Optimized PowerShell** - Lazy loading modules for faster startup - Performance Optimized PowerShell - Lazy loading modules for faster startup
- **🎨 Beautiful Terminal Theme** - Custom Oh-My-Posh configuration with context awareness - Terminal Theme - Custom Oh-My-Posh configuration with context awareness
- **🛠️ Comprehensive Utilities** - 40+ helper functions for faster workflow - Comprehensive Utilities - 40+ helper functions for faster workflow
- **📦 Package Management** - Curated Scoop package lists with automated installation - Package Management - Curated Scoop package lists with automated installation
- **⚙️ Git Configuration** - Extensive aliases and optimized settings - Git Configuration - Extensive aliases and optimized settings
- **🖥️ Windows Terminal Settings** - Custom profiles, keybindings, and color schemes - Windows Terminal Settings - Custom profiles, keybindings, and color schemes
- **💾 Backup & Restore** - Easy configuration backup and migration - Backup & Restore - Easy configuration backup and migration
- **🚀 Automated Setup** - One-command installation with smart defaults - Automated Setup - One-command installation with smart defaults
## Quick Start ## Quick Start
@ -66,18 +66,18 @@ Close and reopen your terminal to see the changes.
## Components ## Components
### 📁 PowerShell Profile ### PowerShell Profile
**Location**: `powershell/user_profile.ps1` Location: powershell/user_profile.ps1
**Features**: Features:
- Lazy loading for faster startup (50%+ improvement) - Lazy loading for faster startup (50%+ improvement)
- Enhanced PSReadLine with ListView predictions - Enhanced PSReadLine with ListView predictions
- 40+ utility functions and aliases - 40+ utility functions and aliases
- Git integration with shortcuts - Git integration with shortcuts
- Network and system utilities - Network and system utilities
**Quick Functions**: Quick Functions:
```powershell ```powershell
# Directory navigation # Directory navigation
.. # Up one level .. # Up one level
@ -100,11 +100,11 @@ which cmd # Find command location
c # Open VS Code in current directory c # Open VS Code in current directory
``` ```
### 🎨 Oh-My-Posh Theme ### Oh-My-Posh Theme
**Location**: `powershell/m1ng.omp.json` Location: powershell/m1ng.omp.json
**Features**: Features:
- Modern powerline design - Modern powerline design
- Git status integration - Git status integration
- Node.js, Python, Go, Docker indicators - Node.js, Python, Go, Docker indicators
@ -112,30 +112,30 @@ c # Open VS Code in current directory
- Time display - Time display
- Root/admin indicator - Root/admin indicator
### 🖥️ Windows Terminal ### Windows Terminal
**Location**: `windows-terminal/settings.json` Location: windows-terminal/settings.json
**Features**: Features:
- Optimized for CaskaydiaCove Nerd Font - Optimized for CaskaydiaCove Nerd Font
- Custom color schemes (One Half Dark, Dracula) - Custom color schemes (One Half Dark, Dracula)
- Vim-inspired pane management keybindings - Vim-inspired pane management keybindings
- Profiles for PowerShell, CMD, WSL, Azure Cloud Shell - Profiles for PowerShell, CMD, WSL, Azure Cloud Shell
- Performance optimizations - Performance optimizations
**Key Bindings**: Key Bindings:
- `Alt+Shift+D` - Duplicate pane - Alt+Shift+D - Duplicate pane
- `Alt+Shift+-` - Split horizontally - Alt+Shift+- - Split horizontally
- `Alt+Shift+|` - Split vertically - Alt+Shift+| - Split vertically
- `Alt+Arrow Keys` - Navigate panes - Alt+Arrow Keys - Navigate panes
- `Ctrl+Shift+F` - Find - Ctrl+Shift+F - Find
- `Alt+Enter` - Fullscreen - Alt+Enter - Fullscreen
### ⚙️ Git Configuration ### Git Configuration
**Location**: `git/.gitconfig` Location: git/.gitconfig
**Features**: Features:
- 30+ useful aliases - 30+ useful aliases
- Histogram diff algorithm - Histogram diff algorithm
- Auto-stash before rebase - Auto-stash before rebase
@ -143,7 +143,7 @@ c # Open VS Code in current directory
- Auto-correct typos - Auto-correct typos
- Global gitignore - Global gitignore
**Useful Aliases**: Useful Aliases:
```bash ```bash
git lg # Beautiful graph log git lg # Beautiful graph log
git sync # Fetch and rebase git sync # Fetch and rebase
@ -153,27 +153,27 @@ git unwip # Undo WIP commit
git aliases # List all aliases git aliases # List all aliases
``` ```
### 📦 Scoop Packages ### Scoop Packages
**Location**: `scoop/packages.json` Location: scoop/packages.json
**Categories**: Categories:
- **Essentials**: git, 7zip, curl, wget, grep, sed - Essentials: git, 7zip, curl, wget, grep, sed
- **Shells**: pwsh, oh-my-posh - Shells: pwsh, oh-my-posh
- **Terminal**: windows-terminal, wezterm - Terminal: windows-terminal, wezterm
- **Editors**: neovim, vscode - Editors: neovim, vscode
- **Development**: nodejs, python, go, rust - Development: nodejs, python, go, rust
- **Tools**: fzf, ripgrep, bat, lazygit, delta - Tools: fzf, ripgrep, bat, lazygit, delta
- **Databases**: postgresql, redis, mysql - Databases: postgresql, redis, mysql
- **Cloud**: aws-cli, azure-cli, terraform - Cloud: aws-cli, azure-cli, terraform
- **Fonts**: Nerd Fonts (CascadiaCode, FiraCode, JetBrainsMono) - Fonts: Nerd Fonts (CascadiaCode, FiraCode, JetBrainsMono)
- **Utilities**: everything, quicklook, powertoys - Utilities: everything, quicklook, powertoys
### 🔧 Tmux Configuration ### Tmux Configuration
**Location**: `tmux/` Location: tmux/
**Features**: Features:
- Custom prefix key (Ctrl+T) - Custom prefix key (Ctrl+T)
- Vim-style navigation - Vim-style navigation
- Custom theme and statusline - Custom theme and statusline
@ -215,7 +215,7 @@ cd scoop
.\export-packages.ps1 .\export-packages.ps1
``` ```
Creates `installed-packages.json` with your current setup. Creates installed-packages.json with your current setup.
### Uninstall ### Uninstall
@ -234,11 +234,11 @@ Creates `installed-packages.json` with your current setup.
### PowerShell Profile ### PowerShell Profile
Edit `powershell/user_profile.ps1` to add your own functions and aliases. Edit powershell/user_profile.ps1 to add your own functions and aliases.
### Oh-My-Posh Theme ### Oh-My-Posh Theme
Customize `powershell/m1ng.omp.json` or create your own theme: Customize powershell/m1ng.omp.json or create your own theme:
```powershell ```powershell
# Browse themes # Browse themes
Get-PoshThemes Get-PoshThemes
@ -249,7 +249,7 @@ oh-my-posh init pwsh --config ~/theme.omp.json | Invoke-Expression
### Git Configuration ### Git Configuration
Edit `git/.gitconfig` or override specific settings: Edit git/.gitconfig or override specific settings:
```powershell ```powershell
git config --global user.name "Your Name" git config --global user.name "Your Name"
git config --global user.email "your@email.com" git config --global user.email "your@email.com"
@ -257,7 +257,7 @@ git config --global user.email "your@email.com"
### Windows Terminal ### Windows Terminal
Customize `windows-terminal/settings.json` for your preferences: Customize windows-terminal/settings.json for your preferences:
- Change color scheme - Change color scheme
- Modify keybindings - Modify keybindings
- Add custom profiles - Add custom profiles
@ -330,38 +330,38 @@ git config --global user.email "your@email.com"
2. Set font in Windows Terminal: 2. Set font in Windows Terminal:
- Open Settings (Ctrl+,) - Open Settings (Ctrl+,)
- Appearance → Font face → CaskaydiaCove Nerd Font - Appearance -> Font face -> CaskaydiaCove Nerd Font
## Project Structure ## Project Structure
``` ```
winfig/ winfig/
├── powershell/ # PowerShell profile and theme |-- powershell/
│ ├── user_profile.ps1 # Main profile | |-- user_profile.ps1
│ └── m1ng.omp.json # Oh-My-Posh theme | `-- m1ng.omp.json
├── windows-terminal/ # Windows Terminal settings |-- windows-terminal/
│ ├── settings.json # Terminal configuration | |-- settings.json
│ └── README.md | `-- README.md
├── git/ # Git configuration |-- git/
│ ├── .gitconfig # Git config with aliases | |-- .gitconfig
│ ├── .gitignore_global # Global gitignore | |-- .gitignore_global
│ └── README.md | `-- README.md
├── scoop/ # Package management |-- scoop/
│ ├── packages.json # Package list | |-- packages.json
│ ├── install-packages.ps1 | |-- install-packages.ps1
│ ├── export-packages.ps1 | |-- export-packages.ps1
│ └── README.md | `-- README.md
├── tmux/ # Tmux configuration |-- tmux/
│ ├── tmux.conf | |-- tmux.conf
│ ├── theme.conf | |-- theme.conf
│ ├── statusline.conf | |-- statusline.conf
│ ├── utility.conf | |-- utility.conf
│ └── macos.conf | `-- macos.conf
├── setup.ps1 # Automated setup |-- setup.ps1
├── uninstall.ps1 # Uninstall script |-- uninstall.ps1
├── backup.ps1 # Backup configurations |-- backup.ps1
├── restore.ps1 # Restore from backup |-- restore.ps1
└── README.md # This file `-- README.md
``` ```
## Tips & Tricks ## Tips & Tricks
@ -402,9 +402,9 @@ Remove-Item $env:TEMP\* -Recurse -Force -ErrorAction SilentlyContinue
### Keyboard Maestro ### Keyboard Maestro
Combine winfig with keyboard launchers: Combine winfig with keyboard launchers:
- **Keypirinha** - Fast launcher (included in Scoop packages) - Keypirinha - Fast launcher (included in Scoop packages)
- **PowerToys Run** - Microsoft's launcher - PowerToys Run - Microsoft's launcher
- **Everything** - Fast file search - Everything - Fast file search
## Contributing ## Contributing
@ -420,16 +420,12 @@ MIT License - See LICENSE file for details
## Acknowledgments ## Acknowledgments
- [Oh-My-Posh](https://ohmyposh.dev/) - Prompt theme engine - Oh-My-Posh (https://ohmyposh.dev/) - Prompt theme engine
- [Scoop](https://scoop.sh/) - Package manager for Windows - Scoop (https://scoop.sh/) - Package manager for Windows
- [Windows Terminal](https://github.com/microsoft/terminal) - Modern terminal - Windows Terminal (https://github.com/microsoft/terminal) - Modern terminal
- [Nerd Fonts](https://www.nerdfonts.com/) - Patched fonts with icons - Nerd Fonts (https://www.nerdfonts.com/) - Patched fonts with icons
## Author ## Author
**m1ngsama** m1ngsama
- GitHub: [@m1ngsama](https://github.com/m1ngsama) GitHub: @m1ngsama (https://github.com/m1ngsama)
---
⭐ If you find winfig useful, please consider giving it a star!

View file

@ -30,14 +30,14 @@ function Backup-ConfigFile {
} }
Copy-Item -Path $source -Destination $destination -Force Copy-Item -Path $source -Destination $destination -Force
Write-ColorOutput " Backed up: $description" "Green" Write-ColorOutput " [OK] Backed up: $description" "Green"
return $true return $true
} catch { } catch {
Write-ColorOutput " Failed: $description - $($_.Exception.Message)" "Red" Write-ColorOutput " [FAIL] Failed: $description - $($_.Exception.Message)" "Red"
return $false return $false
} }
} else { } else {
Write-ColorOutput " Not found: $description" "Yellow" Write-ColorOutput " [WARN] Not found: $description" "Yellow"
return $false return $false
} }
} }
@ -103,7 +103,7 @@ $envVars = @{
path = $env:PATH -split ";" path = $env:PATH -split ";"
} }
$envVars | ConvertTo-Json -Depth 10 | Set-Content $envBackupPath $envVars | ConvertTo-Json -Depth 10 | Set-Content $envBackupPath
Write-ColorOutput " Backed up: Environment variables" "Green" Write-ColorOutput " [OK] Backed up: Environment variables" "Green"
# Backup Scoop packages # Backup Scoop packages
if ($IncludeScoopPackages -and (Get-Command scoop -ErrorAction SilentlyContinue)) { if ($IncludeScoopPackages -and (Get-Command scoop -ErrorAction SilentlyContinue)) {
@ -131,7 +131,7 @@ if ($IncludeScoopPackages -and (Get-Command scoop -ErrorAction SilentlyContinue)
} }
$scoopExport | ConvertTo-Json -Depth 10 | Set-Content (Join-Path $scoopBackupDir "packages.json") $scoopExport | ConvertTo-Json -Depth 10 | Set-Content (Join-Path $scoopBackupDir "packages.json")
Write-ColorOutput " Backed up: $($installed.Count) Scoop packages" "Green" Write-ColorOutput " [OK] Backed up: $($installed.Count) Scoop packages" "Green"
$backupInfo.scoop_packages = $installed.Count $backupInfo.scoop_packages = $installed.Count
} }
@ -158,7 +158,7 @@ if ($Compress) {
$archivePath = "$BackupPath.zip" $archivePath = "$BackupPath.zip"
Compress-Archive -Path $BackupPath -DestinationPath $archivePath -Force Compress-Archive -Path $BackupPath -DestinationPath $archivePath -Force
Remove-Item $BackupPath -Recurse -Force Remove-Item $BackupPath -Recurse -Force
Write-ColorOutput " Compressed to: $archivePath" "Green" Write-ColorOutput " [OK] Compressed to: $archivePath" "Green"
$finalPath = $archivePath $finalPath = $archivePath
} else { } else {
$finalPath = $BackupPath $finalPath = $BackupPath

View file

@ -29,7 +29,7 @@ function Restore-ConfigFile {
if ((Test-Path $destination) -and -not $Force) { if ((Test-Path $destination) -and -not $Force) {
$backup = "$destination.backup.$(Get-Date -Format 'yyyyMMdd-HHmmss')" $backup = "$destination.backup.$(Get-Date -Format 'yyyyMMdd-HHmmss')"
Copy-Item $destination $backup Copy-Item $destination $backup
Write-ColorOutput " Backed up existing: $backup" "Yellow" Write-ColorOutput " [WARN] Backed up existing: $backup" "Yellow"
} }
$destDir = Split-Path $destination -Parent $destDir = Split-Path $destination -Parent
@ -38,14 +38,14 @@ function Restore-ConfigFile {
} }
Copy-Item -Path $source -Destination $destination -Force Copy-Item -Path $source -Destination $destination -Force
Write-ColorOutput " Restored: $description" "Green" Write-ColorOutput " [OK] Restored: $description" "Green"
return $true return $true
} catch { } catch {
Write-ColorOutput " Failed: $description - $($_.Exception.Message)" "Red" Write-ColorOutput " [FAIL] Failed: $description - $($_.Exception.Message)" "Red"
return $false return $false
} }
} else { } else {
Write-ColorOutput " Not found in backup: $description" "Yellow" Write-ColorOutput " [WARN] Not found in backup: $description" "Yellow"
return $false return $false
} }
} }
@ -108,7 +108,7 @@ if ($RestoreScoopPackages) {
Write-Section "Scoop Packages" Write-Section "Scoop Packages"
if (-not (Get-Command scoop -ErrorAction SilentlyContinue)) { if (-not (Get-Command scoop -ErrorAction SilentlyContinue)) {
Write-ColorOutput " Scoop is not installed" "Red" Write-ColorOutput " [FAIL] Scoop is not installed" "Red"
Write-ColorOutput " Install Scoop first: https://scoop.sh" "Yellow" Write-ColorOutput " Install Scoop first: https://scoop.sh" "Yellow"
} else { } else {
$scoopBackupPath = Join-Path $BackupPath "scoop\packages.json" $scoopBackupPath = Join-Path $BackupPath "scoop\packages.json"
@ -138,12 +138,12 @@ if ($RestoreScoopPackages) {
} }
} }
Write-ColorOutput " Installed: $installed packages" "Green" Write-ColorOutput " [OK] Installed: $installed packages" "Green"
if ($failed -gt 0) { if ($failed -gt 0) {
Write-ColorOutput " Failed: $failed packages" "Red" Write-ColorOutput " [FAIL] Failed: $failed packages" "Red"
} }
} else { } else {
Write-ColorOutput " No Scoop package list found in backup" "Yellow" Write-ColorOutput " [WARN] No Scoop package list found in backup" "Yellow"
} }
} }
} }

View file

@ -40,7 +40,7 @@ $export = @{
# Save to JSON # Save to JSON
$export | ConvertTo-Json -Depth 10 | Set-Content $outputFile $export | ConvertTo-Json -Depth 10 | Set-Content $outputFile
Write-ColorOutput " Exported $($installed.Count) packages to: $outputFile" "Green" Write-ColorOutput "[OK] Exported $($installed.Count) packages to: $outputFile" "Green"
Write-ColorOutput "" Write-ColorOutput ""
Write-ColorOutput "Buckets: $($buckets.Count)" "Cyan" Write-ColorOutput "Buckets: $($buckets.Count)" "Cyan"
Write-ColorOutput "Packages: $($installed.Count)" "Cyan" Write-ColorOutput "Packages: $($installed.Count)" "Cyan"

View file

@ -26,9 +26,9 @@ function Install-Package {
scoop install $packageName scoop install $packageName
if ($LASTEXITCODE -eq 0) { if ($LASTEXITCODE -eq 0) {
Write-ColorOutput " Installed: $packageName" "Green" Write-ColorOutput " [OK] Installed: $packageName" "Green"
} else { } else {
Write-ColorOutput " Failed: $packageName" "Red" Write-ColorOutput " [FAIL] Failed: $packageName" "Red"
} }
} }

View file

@ -42,9 +42,9 @@ function Copy-ConfigFile {
} }
Copy-Item -Path $source -Destination $destination -Force Copy-Item -Path $source -Destination $destination -Force
Write-ColorOutput " Copied: $description" "Green" Write-ColorOutput " [OK] Copied: $description" "Green"
} catch { } catch {
Write-ColorOutput " Failed: $description - $($_.Exception.Message)" "Red" Write-ColorOutput " [FAIL] Failed: $description - $($_.Exception.Message)" "Red"
} }
} }
@ -113,7 +113,7 @@ if (-not $SkipTerminal) {
$backupPath = "$terminalSettingsPath.backup.$(Get-Date -Format 'yyyyMMdd-HHmmss')" $backupPath = "$terminalSettingsPath.backup.$(Get-Date -Format 'yyyyMMdd-HHmmss')"
if (-not $DryRun) { if (-not $DryRun) {
Copy-Item $terminalSettingsPath $backupPath Copy-Item $terminalSettingsPath $backupPath
Write-ColorOutput " Backed up existing settings to: $backupPath" "Green" Write-ColorOutput " [OK] Backed up existing settings to: $backupPath" "Green"
} else { } else {
Write-ColorOutput " [DRY RUN] Would backup to: $backupPath" "Yellow" Write-ColorOutput " [DRY RUN] Would backup to: $backupPath" "Yellow"
} }
@ -121,7 +121,7 @@ if (-not $SkipTerminal) {
Copy-ConfigFile $sourceTerminalSettings $terminalSettingsPath "Windows Terminal settings" Copy-ConfigFile $sourceTerminalSettings $terminalSettingsPath "Windows Terminal settings"
} else { } else {
Write-ColorOutput " Windows Terminal not found or not installed" "Yellow" Write-ColorOutput " [WARN] Windows Terminal not found or not installed" "Yellow"
} }
} }
@ -130,13 +130,13 @@ if (-not $SkipScoop) {
Write-Section "Scoop Package Manager" Write-Section "Scoop Package Manager"
if (Get-Command scoop -ErrorAction SilentlyContinue) { if (Get-Command scoop -ErrorAction SilentlyContinue) {
Write-ColorOutput " Scoop is already installed" "Green" Write-ColorOutput " [OK] Scoop is already installed" "Green"
Write-ColorOutput "" Write-ColorOutput ""
Write-ColorOutput " Install packages with:" "Cyan" Write-ColorOutput " Install packages with:" "Cyan"
Write-ColorOutput " cd scoop" "White" Write-ColorOutput " cd scoop" "White"
Write-ColorOutput " .\install-packages.ps1" "White" Write-ColorOutput " .\install-packages.ps1" "White"
} else { } else {
Write-ColorOutput " Scoop is not installed" "Red" Write-ColorOutput " [FAIL] Scoop is not installed" "Red"
Write-ColorOutput "" Write-ColorOutput ""
Write-ColorOutput " Install Scoop with:" "Yellow" Write-ColorOutput " Install Scoop with:" "Yellow"
Write-ColorOutput " Set-ExecutionPolicy RemoteSigned -Scope CurrentUser" "White" Write-ColorOutput " Set-ExecutionPolicy RemoteSigned -Scope CurrentUser" "White"

View file

@ -24,14 +24,14 @@ function Remove-ConfigFile {
if (Test-Path $path) { if (Test-Path $path) {
if ($Force) { if ($Force) {
Remove-Item $path -Force Remove-Item $path -Force
Write-ColorOutput " Removed: $description" "Green" Write-ColorOutput " [OK] Removed: $description" "Green"
} else { } else {
$backup = "$path.backup.$(Get-Date -Format 'yyyyMMdd-HHmmss')" $backup = "$path.backup.$(Get-Date -Format 'yyyyMMdd-HHmmss')"
Move-Item $path $backup Move-Item $path $backup
Write-ColorOutput " Backed up to: $backup" "Green" Write-ColorOutput " [OK] Backed up to: $backup" "Green"
} }
} else { } else {
Write-ColorOutput " Not found: $description" "Yellow" Write-ColorOutput " [WARN] Not found: $description" "Yellow"
} }
} }
@ -71,7 +71,7 @@ if ($RemoveModules) {
foreach ($module in $modules) { foreach ($module in $modules) {
if (Get-Module -ListAvailable -Name $module) { if (Get-Module -ListAvailable -Name $module) {
Uninstall-Module $module -Force -ErrorAction SilentlyContinue Uninstall-Module $module -Force -ErrorAction SilentlyContinue
Write-ColorOutput " Removed: $module" "Green" Write-ColorOutput " [OK] Removed: $module" "Green"
} }
} }
} }