mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-23 05:01:37 +01:00
Improved the scripts
This commit is contained in:
parent
b8d42c207b
commit
f7f3f0f148
@ -11,7 +11,7 @@ close-file-explorer.ps1, closes Microsoft File Explorer gracefully
|
|||||||
close-program.ps1, closes the given program gracefully
|
close-program.ps1, closes the given program gracefully
|
||||||
close-thunderbird.ps1, closes Mozilla Thunderbird gracefully
|
close-thunderbird.ps1, closes Mozilla Thunderbird gracefully
|
||||||
close-windows-terminal.ps1, closes Windows Terminal gracefully
|
close-windows-terminal.ps1, closes Windows Terminal gracefully
|
||||||
configure-git.ps1, sets up the Git configuration
|
configure-git.ps1, sets up the Git user configuration
|
||||||
csv-to-text.ps1, converts the given CSV file into a text list
|
csv-to-text.ps1, converts the given CSV file into a text list
|
||||||
daily-tasks.sh, execute PowerShell scripts automatically as daily tasks (Linux only)
|
daily-tasks.sh, execute PowerShell scripts automatically as daily tasks (Linux only)
|
||||||
decrypt-file.ps1, decrypts the given file
|
decrypt-file.ps1, decrypts the given file
|
||||||
@ -115,4 +115,4 @@ write-rot13.ps1, encodes or decodes the given text with ROT13
|
|||||||
write-typewriter.ps1, writes the given text with the typewriter effect
|
write-typewriter.ps1, writes the given text with the typewriter effect
|
||||||
write-uppercase.ps1, writes the given text in uppercase letters
|
write-uppercase.ps1, writes the given text in uppercase letters
|
||||||
write-vertical.ps1, writes the given text in vertical direction
|
write-vertical.ps1, writes the given text in vertical direction
|
||||||
zip-dir.ps1, creates a zip archive of the given folder
|
zip-dir.ps1, creates a zip archive of the given directory
|
||||||
|
Can't render this file because it has a wrong number of fields in line 103.
|
@ -19,7 +19,7 @@ The following PowerShell scripts can be found in the [Scripts/](Scripts/) subfol
|
|||||||
* [close-program.ps1](Scripts/close-program.ps1) - closes the given program gracefully
|
* [close-program.ps1](Scripts/close-program.ps1) - closes the given program gracefully
|
||||||
* [close-thunderbird.ps1](Scripts/close-thunderbird.ps1) - closes Mozilla Thunderbird gracefully
|
* [close-thunderbird.ps1](Scripts/close-thunderbird.ps1) - closes Mozilla Thunderbird gracefully
|
||||||
* [close-windows-terminal.ps1](Scripts/close-windows-terminal.ps1) - closes Windows Terminal gracefully
|
* [close-windows-terminal.ps1](Scripts/close-windows-terminal.ps1) - closes Windows Terminal gracefully
|
||||||
* [configure-git.ps1](Scripts/configure-git.ps1) - sets up the Git configuration
|
* [configure-git.ps1](Scripts/configure-git.ps1) - sets up the Git user configuration
|
||||||
* [csv-to-text.ps1](Scripts/csv-to-text.ps1) - converts the given CSV file into a text list
|
* [csv-to-text.ps1](Scripts/csv-to-text.ps1) - converts the given CSV file into a text list
|
||||||
* [daily-tasks.sh](Scripts/daily-tasks.sh) - execute PowerShell scripts automatically as daily tasks (Linux only)
|
* [daily-tasks.sh](Scripts/daily-tasks.sh) - execute PowerShell scripts automatically as daily tasks (Linux only)
|
||||||
* [decrypt-file.ps1](Scripts/decrypt-file.ps1) - encrypts the given file
|
* [decrypt-file.ps1](Scripts/decrypt-file.ps1) - encrypts the given file
|
||||||
@ -123,7 +123,7 @@ The following PowerShell scripts can be found in the [Scripts/](Scripts/) subfol
|
|||||||
* [write-typewriter.ps1](Scripts/write-typewriter.ps1) - writes the given text with the typewriter effect
|
* [write-typewriter.ps1](Scripts/write-typewriter.ps1) - writes the given text with the typewriter effect
|
||||||
* [write-uppercase.ps1](Scripts/write-uppercase.ps1) - writes the given text in uppercase letters
|
* [write-uppercase.ps1](Scripts/write-uppercase.ps1) - writes the given text in uppercase letters
|
||||||
* [write-vertical.ps1](Scripts/write-vertical.ps1) - writes the given text in vertical direction
|
* [write-vertical.ps1](Scripts/write-vertical.ps1) - writes the given text in vertical direction
|
||||||
* [zip-dir.ps1](Scripts/zip-dir.ps1) - creates a zip archive of the given folder
|
* [zip-dir.ps1](Scripts/zip-dir.ps1) - creates a zip archive of the given directory
|
||||||
|
|
||||||
|
|
||||||
What is PowerShell?
|
What is PowerShell?
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
#!/snap/bin/powershell
|
#!/snap/bin/powershell
|
||||||
<#
|
<#
|
||||||
.SYNTAX ./configure-git.ps1
|
.SYNTAX ./configure-git.ps1 [<full-name>] [<email-address>] [<favorite-editor>]
|
||||||
.DESCRIPTION sets up the Git configuration
|
.DESCRIPTION sets up the Git user configuration
|
||||||
.LINK https://github.com/fleschutz/PowerShell
|
.LINK https://github.com/fleschutz/PowerShell
|
||||||
.NOTES Author: Markus Fleschutz / License: CC0
|
.NOTES Author: Markus Fleschutz / License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
param($FullName = "", $EmailAddress = "", $FavoriteEditor = "")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
git --version
|
git --version
|
||||||
} catch {
|
} catch {
|
||||||
@ -13,9 +15,15 @@ try {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
$FullName = read-host "Enter your full name"
|
if ($FullName -eq "") {
|
||||||
$EmailAddress = read-host "Enter your e-mail address"
|
$FullName = read-host "Enter your full name"
|
||||||
$FavoriteEditor = read-host "Enter your favorite text editor (emacs,nano,vi,vim,...)"
|
}
|
||||||
|
if ($EmailAddress -eq "") {
|
||||||
|
$EmailAddress = read-host "Enter your e-mail address"
|
||||||
|
}
|
||||||
|
if ($FavoriteEditor -eq "") {
|
||||||
|
$FavoriteEditor = read-host "Enter your favorite text editor (emacs,nano,vi,vim,...)"
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
git config --global user.name $FullName
|
git config --global user.name $FullName
|
||||||
@ -25,7 +33,7 @@ try {
|
|||||||
git config --global core.autocrlf false
|
git config --global core.autocrlf false
|
||||||
git config --global core.symlinks true
|
git config --global core.symlinks true
|
||||||
git config --global init.defaultBranch main
|
git config --global init.defaultBranch main
|
||||||
write-output "OK - your Git configuration is now:"
|
write-output "OK - your Git user configuration is now:"
|
||||||
git config --list
|
git config --list
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
#!/snap/bin/powershell
|
#!/snap/bin/powershell
|
||||||
<#
|
<#
|
||||||
.SYNTAX ./zip-dir.ps1 [<path-to-folder>]
|
.SYNTAX ./zip-dir.ps1 [<directory>]
|
||||||
.DESCRIPTION creates a zip archive of the given folder
|
.DESCRIPTION creates a zip archive of the given directory
|
||||||
.LINK https://github.com/fleschutz/PowerShell
|
.LINK https://github.com/fleschutz/PowerShell
|
||||||
.NOTES Author: Markus Fleschutz / License: CC0
|
.NOTES Author: Markus Fleschutz / License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param([string]$Path = "")
|
param([string]$Directory = "")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($Path -eq "" ) {
|
if ($Directory -eq "" ) {
|
||||||
$URL = read-host "Enter path to folder"
|
$Directory = read-host "Enter path to directory to zip"
|
||||||
}
|
}
|
||||||
|
|
||||||
compress-archive -path $Path -destinationPath $Path.zip
|
compress-archive -path $Directory -destinationPath $Directory.zip
|
||||||
write-output "OK - folder has been compressed to $($Path).zip"
|
write-output "OK - created zip archive $($Directory).zip"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user