Created
December 23, 2020 01:43
-
-
Save MichaelDimmitt/c3d191ec5bfeea10ec01bc592101740b to your computer and use it in GitHub Desktop.
Pure copy and paste from: https://github.com/MenkeTechnologies/zpwr/blob/master/scripts/crossOSCommands.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#{{{ MARK:Header | |
#************************************************************** | |
##### Author: JACOBMENKE | |
##### Date: Mon Jul 10 12:10:25 EDT 2017 | |
##### Purpose: bash script to contain open, copy and paste commands | |
##### Notes: | |
#}}}*********************************************************** | |
if [[ -z "$ZPWR_OS_TYPE" ]]; then | |
export ZPWR_OS_TYPE="$(uname -s | perl -e 'print lc<>')" | |
fi | |
function zpwrGetOpenCommand(){ | |
local open_cmd | |
case "$ZPWR_OS_TYPE" in | |
darwin*) open_cmd='open' | |
;; | |
cygwin*) open_cmd='cygstart' | |
;; | |
linux*) | |
if [[ "$(uname -r)" != *icrosoft* ]];then | |
open_cmd='nohup xdg-open' | |
else | |
open_cmd='cmd.exe /c start ""' | |
fi | |
;; | |
msys*) open_cmd='start ""' | |
;; | |
*) echo "Platform $ZPWR_OS_TYPE not supported" | |
return 1 | |
;; | |
esac | |
echo "$open_cmd" | |
} | |
function zpwrGetPasteCommand(){ | |
local paste_cmd | |
case "$ZPWR_OS_TYPE" in | |
darwin*) | |
paste_cmd='pbpaste' | |
;; | |
cygwin*) | |
paste_cmd="powershell.exe -noprofile -command 'Get-Clipboard'" | |
;; | |
linux*) | |
if [[ "$(uname -r)" != *icrosoft* ]];then | |
paste_cmd='xclip -o -sel clip' | |
else | |
paste_cmd="powershell.exe -noprofile -command 'Get-Clipboard'" | |
fi | |
;; | |
msys*) | |
paste_cmd="powershell.exe -noprofile -command 'Get-Clipboard'" | |
;; | |
*) | |
echo "Platform $ZPWR_OS_TYPE not supported" | |
return 1 | |
;; | |
esac | |
echo "$paste_cmd" | |
} | |
function zpwrGetCopyCommand(){ | |
local copy_cmd | |
case "$ZPWR_OS_TYPE" in | |
darwin*) | |
copy_cmd='pbcopy' | |
;; | |
cygwin*) | |
copy_cmd='clip.exe' | |
;; | |
linux*) | |
if [[ "$(uname -r)" != *icrosoft* ]];then | |
copy_cmd='xclip -i -sel clip' | |
else | |
copy_cmd='clip.exe' | |
fi | |
;; | |
msys*) | |
copy_cmd='clip.exe' | |
;; | |
*) | |
echo "Platform $ZPWR_OS_TYPE not supported" | |
return 1 | |
;; | |
esac | |
echo "$copy_cmd" | |
} | |
export ZPWR_OPEN_CMD="$(zpwrGetOpenCommand)" | |
export ZPWR_COPY_CMD="$(zpwrGetCopyCommand)" | |
export ZPWR_PASTE_CMD="$(zpwrGetPasteCommand)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment