diff --git a/Scripts/cd-temp.ps1 b/Scripts/cd-temp.ps1 index 49c58d6d..5245d9b9 100644 --- a/Scripts/cd-temp.ps1 +++ b/Scripts/cd-temp.ps1 @@ -12,8 +12,13 @@ Author: Markus Fleschutz ยท License: CC0 #> +function GetTempDir { + if ($IsLinux) { return "/tmp" } + return "$env:TEMP" +} + try { - $TargetDir = resolve-path "$env:TEMP" + $TargetDir = resolve-path GetTempDir if (-not(test-path "$TargetDir" -pathType container)) { throw "Temporary folder at ๐Ÿ“‚$TargetDir doesn't exist (yet)" } diff --git a/Scripts/give-reply.ps1 b/Scripts/give-reply.ps1 index 409e397a..707b2309 100644 --- a/Scripts/give-reply.ps1 +++ b/Scripts/give-reply.ps1 @@ -15,6 +15,11 @@ param([string]$text = "") +function GetTempDir { + if ($IsLinux) { return "/tmp" } + return "$env:TEMP" +} + try { # print reply on the console: " โ† $text" @@ -29,7 +34,7 @@ try { } # remember last reply: - "$text" > "$env:TEMP/last_reply.txt" + "$text" > "$(GetTempDir)/last_reply_given.txt" exit 0 # success } catch { "โš ๏ธ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" diff --git a/Scripts/open-temporary-folder.ps1 b/Scripts/open-temporary-folder.ps1 index 8e57e0c5..f15ae94b 100644 --- a/Scripts/open-temporary-folder.ps1 +++ b/Scripts/open-temporary-folder.ps1 @@ -11,8 +11,13 @@ https://github.com/fleschutz/PowerShell #> +function GetTempDir { + if ($IsLinux) { return "/tmp" } + return "$env:TEMP" +} + try { - $TargetDir = resolve-path "$env:TEMP" + $TargetDir = resolve-path GetTempDir if (-not(test-path "$TargetDir" -pathType container)) { throw "Temporary folder at ๐Ÿ“‚$TargetDir doesn't exist (yet)" } diff --git a/Scripts/repeat-last-reply.ps1 b/Scripts/repeat-last-reply.ps1 index 8ba4c81c..07309c55 100644 --- a/Scripts/repeat-last-reply.ps1 +++ b/Scripts/repeat-last-reply.ps1 @@ -11,9 +11,14 @@ https://github.com/fleschutz/PowerShell #> -if (test-path "$env:TEMP/last_reply.txt" -pathType leaf) { +function GetTempDir { + if ($IsLinux) { return "/tmp" } + return "$env:TEMP" +} + +if (test-path "$(GetTempDir)/last_reply_given.txt" -pathType leaf) { $Reply = "It was: " - $Reply += Get-Content "$env:TEMP/.last_reply.txt" + $Reply += Get-Content "$(GetTempDir)/last_reply_given.txt" } else { $Reply = "Sorry, I can't remember." }