From 945c07606e40eb199874743e0fffcaa4acc1f0fc Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Tue, 24 Aug 2021 21:46:11 +0200 Subject: [PATCH] Add install-github-cli.ps1 --- Data/scripts.csv | 1 + README.md | 1 + Scripts/install-github-cli.ps1 | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 Scripts/install-github-cli.ps1 diff --git a/Data/scripts.csv b/Data/scripts.csv index 805d92e3..f7d53c82 100644 --- a/Data/scripts.csv +++ b/Data/scripts.csv @@ -75,6 +75,7 @@ fetch-repos.ps1, fetches updates for all Git repositories under the current/give generate-qrcode.ps1, generates a QR code hibernate.ps1, enables hibernate mode for the local computer (needs admin rights) inspect-exe.ps1, prints basic information of the given executable file +install-github-cli.ps1, installs GitHub CLI install-google-chrome.ps1, installs the Google Chrome browser install-knot-resolver.ps1, installs the Knot Resolver (needs admin rights) install-signal-cli.ps1, installs signal-cli from github.com/AsamK/signal-cli diff --git a/README.md b/README.md index 40d8e54c..ff0f148a 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ Mega Collection of PowerShell Scripts * [check-windows-system-files.ps1](Scripts/check-windows-system-files.ps1) - checks the validity of the Windows system files (needs admin rights) * [enable-crash-dumps.ps1](Scripts/enable-crash-dumps.ps1) - enables the writing of crash dumps * [hibernate.ps1](Scripts/hibernate.ps1) - enables hibernate mode for the local computer (needs admin rights) +* [install-github-cli.ps1](Scripts/install-github-cli.ps1) - installs GitHub CLI * [install-google-chrome.ps1](Scripts/install-google-chrome.ps1) - installs the Google Chrome browser * [install-knot-resolver.ps1](Scripts/install-knot-resolver.ps1) - installs the Knot Resolver (needs admin rights) * [install-ssh-client.ps1](Scripts/install-ssh-client.ps1) - installs the SSH client (needs admin rights) diff --git a/Scripts/install-github-cli.ps1 b/Scripts/install-github-cli.ps1 new file mode 100644 index 00000000..f6fc5ef0 --- /dev/null +++ b/Scripts/install-github-cli.ps1 @@ -0,0 +1,33 @@ +<# +.SYNOPSIS + install-github-cli.ps1 +.DESCRIPTION + Installs GitHub CLI +.EXAMPLE + PS> .\install-github-cli.ps1 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz + License: CC0 +#> + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + if ($IsMacOS) { + brew install gh + } elseif ($IsLinux) { + curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null + sudo apt update + sudo apt install gh + } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "✔️ installed GitHub CLI in $Elapsed sec" + exit 0 +} catch { + write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +}