-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew.ps1
More file actions
35 lines (28 loc) · 706 Bytes
/
new.ps1
File metadata and controls
35 lines (28 loc) · 706 Bytes
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
$help = 'Create new powershell scripts
> new name1 name2 ... nameN
will create:
$scripts/name1.ps1
$scripts/name2.ps1
...
$scripts/nameN.ps1
And then open each file with the "editor" alias defined in $profile
'
$pths=@((join-path $scripts "readme.md"))
if ($args.length) {
foreach ($arg in $args) {
$pth = join-path $scripts $arg
$pth += ($pth.endswith(".ps1")) ? "" : ".ps1"
touch $pth
$pths += $pth
}
} else {
echo $help
}
# echo $pths
editor ($pths)
# clean up
foreach ($file in (dir $scripts)) {
if (!$file.length) {
rm $file
}
}