Created
June 29, 2025 13:19
-
-
Save wazeerc/bae61b537802fede396a6aa99c94d85a to your computer and use it in GitHub Desktop.
zsh Script to create new Excalidraw in VS Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Create new Excalidraw in current directory | |
function New-File { | |
param( | |
[string]$FileName | |
) | |
# Check if we're in a Git repository | |
$isGitRepo = Test-Path -Path ".git" -PathType Container | |
if ($isGitRepo) { | |
# Create designs directory if it doesn't exist | |
$designsPath = Join-Path -Path (Get-Location) -ChildPath "designs" | |
if (-not (Test-Path -Path $designsPath)) { | |
New-Item -ItemType Directory -Path $designsPath | Out-Null | |
Write-Host "Created designs directory" -ForegroundColor Green | |
} | |
# Create the file in the designs folder | |
$Path = Join-Path -Path $designsPath -ChildPath ("$FileName.excalidraw") | |
New-Item -ItemType File -Path $Path | |
# Check if .gitignore exists and update it to include designs folder | |
$gitignorePath = Join-Path -Path (Get-Location) -ChildPath ".gitignore" | |
$designsInGitignore = $false | |
if (Test-Path -Path $gitignorePath) { | |
$gitignoreContent = Get-Content -Path $gitignorePath | |
$designsInGitignore = $gitignoreContent -contains "designs/" -or $gitignoreContent -contains "designs" | |
if (-not $designsInGitignore) { | |
Add-Content -Path $gitignorePath -Value "`ndesigns/" | |
Write-Host "Added designs/ to .gitignore" -ForegroundColor Green | |
} | |
} else { | |
# Create .gitignore with designs/ entry | |
Set-Content -Path $gitignorePath -Value "designs/" | |
Write-Host "Created .gitignore with designs/ entry" -ForegroundColor Green | |
} | |
} else { | |
# Not a Git repo, create file in current directory | |
$Path = Join-Path -Path (Get-Location) -ChildPath ("$FileName.excalidraw") | |
New-Item -ItemType File -Path $Path | |
} | |
} | |
Set-Alias -Name excalidraw -Value New-File |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment