-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPwrSearch.psm1
91 lines (81 loc) · 1.72 KB
/
PwrSearch.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
########################################################
# 'go' command and targets
if( $global:go_locations -eq $null )
{
$global:go_locations = @{};
}
function _sd
{
param([string] $pattern,[switch]$All)
$pattern = $pattern.Replace("/","\\");
import-module ($PSScriptRoot+'\SearchDir.dll')
[string[]]$sd
if ($env:_XROOT -ne $null )
{
$sd = $env:_XROOT
}
else
{
$sd = (get-location)
}
[string[]]$exDirs=("objd","obj","objr","objc")
if ($env:_XROOT -ne $null )
{
$exDirs+=$env:_XROOT+"\SetupAuthoring"
$exDirs+=$env:_XROOT+"\Tools"
$exDirs+=$env:_XROOT+"\public"
}
if ($env:init -ne $null )
{
$exDirs+=$env:init
}
if ( $all.IsPresent )
{
Search-Directory -Search $sd -ExcludeDirectories $exDirs -Pattern $pattern -All
}
else
{
Search-Directory -Search $sd -ExcludeDirectories $exDirs -Pattern $pattern
}
}
function _gosd
{
param([string] $pattern)
$dir = $null
if (test-path $pattern)
{
$dir = (gi $pattern)
}
else
{
$dir = (_sd $pattern)
}
if (!($dir -eq $null))
{
$fn= $dir.FullName
pushd $fn
return $true
}
return $false
}
function global:Goto-KnownLocation([string] $location)
{
if ( $go_locations.ContainsKey($location) )
{
set-location $go_locations[$location];
}
else
{
if (!(_gosd $location))
{
write-output "The following locations are defined:";
write-output $go_locations;
}
}
}
$go_locations["home"]="~"
$go_locations["src"]="C:\src"
$go_locations["bin"]="C:\bin"
$go_locations["scripts"]=((get-item $profile).Directory.FullName)
set-alias go Goto-KnownLocation -scope global
Export-ModuleMember -Function Goto-KnownLocation