From 0e66511c17b2358db4426a6282beb02c9c0bab29 Mon Sep 17 00:00:00 2001 From: Drew Malzahn Date: Wed, 19 May 2021 01:37:50 -0400 Subject: [PATCH] Don't add common or excluded directories to the db --- z.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/z.ps1 b/z.ps1 index a92f904..7d852a7 100644 --- a/z.ps1 +++ b/z.ps1 @@ -83,11 +83,15 @@ function Add-ToZDatabase { $Add += "\"; } - # Check so we don't match $HOME - if ($Add -eq $env:HOME) { return $null; } + # Check so we don't match $HOME. The logic here (I think) is that it's + # already easy to jump to home with ~, we don't need another shortcut. + if (($Add -eq $env:HOME) -or ($Add -eq $env:USERPROFILE)) { + Set-Location -Path $Add; return; + } # Don't track excluded directories - if (($env:_Z_EXCLUDE_DIRS -ne $null) -and ($env:_Z_EXCLUDE_DIRS -contains $Add)) { + if (($null -ne $env:_Z_EXCLUDE_DIRS) -and ($env:_Z_EXCLUDE_DIRS -contains $Add)) { + Set-Location -Path $Add; return; }