Skip to content

Instantly share code, notes, and snippets.

@tanishqmanuja
Created January 4, 2025 08:47
Show Gist options
  • Save tanishqmanuja/d651e19e1ff4f14bb9e1202c008032d3 to your computer and use it in GitHub Desktop.
Save tanishqmanuja/d651e19e1ff4f14bb9e1202c008032d3 to your computer and use it in GitHub Desktop.
PowerShell Quick Project Open

πŸͺ„ Quick Project Open

demo-quick-project.webm

πŸ“¦ Requirements

  1. fd - https://github.com/sharkdp/fd

    winget install sharkdp.fd
  2. fzf - https://github.com/junegunn/fzf

    winget install fzf

πŸ‘¨β€πŸ’» Setup

After installing these, open your powershell profile by running

code $profile

or if code is not installed

notepad $profile
function c {
$code_path = "C:\Users\tanishq\AppData\Local\Programs\Microsoft VS Code\Code.exe"
if($args) { & $code_path $args > $null }
else { & $code_path . > $null }
}
function f {
$directories = @(
"C:\Users\tanishq\Projects",
"C:\Users\tanishq\Learning"
)
$query = $args -join ' '
$dir = FuzzySearch -Directories $directories -Query $query
if ($dir) { Set-Location $dir }
}
function ff {
f @args
c
}
# Helper
function FuzzySearch {
param (
[string[]]$Directories,
[string]$Query
)
$searchParams = @(
'--type', 'd',
'.', $Directories,
'--exact-depth', '2'
)
$dir = if ($Query) {
fd @searchParams | fzf --layout=reverse --query $Query
} else {
fd @searchParams | fzf --layout=reverse
}
if ($dir -is [string]) { return $dir }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment