From 8cf0a2372fce74d0e729325b0d5e8fae39b60be7 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Fri, 26 May 2023 14:19:58 +0200 Subject: [PATCH] Add cd-logs.ps1 --- Scripts/cd-logs.ps1 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Scripts/cd-logs.ps1 diff --git a/Scripts/cd-logs.ps1 b/Scripts/cd-logs.ps1 new file mode 100644 index 00000000..ce4ca441 --- /dev/null +++ b/Scripts/cd-logs.ps1 @@ -0,0 +1,29 @@ +<# +.SYNOPSIS + Sets the working directory to the logs folder +.DESCRIPTION + This PowerShell script changes the current working directory to the logs directory. +.EXAMPLE + PS> ./cd-logs + 📂/var/logs +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function GetLogsDir { + if ($IsLinux) { return "/var/logs" } + $WinDir = [System.Environment]::GetFolderPath('Windows') + return "$WinDir\Logs" +} + +try { + $Path = GetLogsDir + Set-Location "$Path" + "📂$Path" + exit 0 # success +} catch { + "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} \ No newline at end of file