-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMicrosoft.PowerShell_profile.ps1
More file actions
137 lines (114 loc) · 3.51 KB
/
Microsoft.PowerShell_profile.ps1
File metadata and controls
137 lines (114 loc) · 3.51 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
Function gitshort() {
param (
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[string]$CommitMessage
)
$mainExists = git show-ref refs/heads/main
$masterExists = git show-ref refs/heads/master
$currentBranch = git rev-parse --abbrev-ref HEAD
if ($mainExists) {
$baseBranch = 'main'
} elseif ($masterExists) {
$baseBranch = 'master'
} else {
Write-Error "No main or master branch found. Please create one of them first."
return
}
if ($currentBranch -eq $baseBranch) {
Write-Warning "You are on the main/master branch!"
$input = Read-Host "Are you sure you want to continue? (Y/N)"
if ($input.ToUpper() -ne 'Y') {
Write-Host "Exiting"
return
}
}
git pull --tags
git add -A :/
git commit -m "$CommitMessage"
git pull
git push
}
Function gitshortpr() {
param (
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[string]$CommitMessage
)
git pull --tags
git add -A :/
git commit -m "$CommitMessage"
git pull
git push
gh pr create --title "$CommitMessage" --fill
}
Function gitshortprdraft() {
param (
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[string]$CommitMessage
)
git pull --tags
git add -A :/
git commit -m "$CommitMessage"
git pull
git push
gh pr create --title "$CommitMessage" --fill --draft
}
Function gitnewbranch() {
param (
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[string]$BranchName
)
$mainExists = git show-ref refs/heads/main
$masterExists = git show-ref refs/heads/master
if ($mainExists) {
$baseBranch = 'main'
} elseif ($masterExists) {
$baseBranch = 'master'
} else {
Write-Error "No main or master branch found. Please create one of them first."
return
}
git checkout $baseBranch
git pull --all --tags -f
git checkout -b $BranchName
git push --set-upstream origin $BranchName
git pull
}
Function gitdependabotbranch() {
param (
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[string]$BranchName
)
git fetch origin
git checkout $BranchName
git commit --allow-empty -m "Empty-Commit"
git push
}
Function gitcannotlockref() {
git gc --prune=now
git remote prune origin
}
Function Generate-Password() {
param (
[Parameter(Mandatory=$False)]
[int]$Length = 20,
[Parameter(Mandatory=$False)]
[int]$NonAlphaCharsCount = 4
)
# Define character sets
$nonAlphaChars = [char[]]('!@#$%&_')
$alphaNumericChars = [char[]]('23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjklmnpqrstuvwxyz')
# Generate random alpha-numeric characters
$alphaNumeric = for ($i = 1; $i -le ($Length - $NonAlphaCharsCount); $i++) {
Get-Random -InputObject $alphaNumericChars -Count 1
}
# Generate random non-alphanumeric characters
$nonAlpha = for ($i = 1; $i -le $NonAlphaCharsCount; $i++) {
Get-Random -InputObject $nonAlphaChars -Count 1
}
# Combine both sets of characters
$passwordChars = $alphaNumeric + $nonAlpha
# Shuffle the combined characters
$shuffledPasswordChars = $passwordChars | Get-Random -Count $Length
# Return the generated password as a string
return -join $shuffledPasswordChars
}