Skip to content

Instantly share code, notes, and snippets.

@johndalton
Last active February 27, 2016 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johndalton/55c9364890d15e21f814 to your computer and use it in GitHub Desktop.
Save johndalton/55c9364890d15e21f814 to your computer and use it in GitHub Desktop.
#!/bin/bash
ksp="$HOME/Library/Application Support/Steam/SteamApps/common/Kerbal Space Program/KSP.app/Contents"
unity="/Applications/Unity/Unity.app/Contents/PlaybackEngines/MacStandaloneSupport/Variations/macosx64_nondevelopment_mono/UnityPlayer.app/Contents"
transfer() {
# Take an optional destination argument in case the destination file has a different name.
if [ "Z$2" != "Z" ]
then
dest=$2
else
dest=$1
fi
mv "$ksp/$dest" "$ksp/$dest.bak"
cp "$unity/$1" "$ksp/$dest"
}
transfer "Data/Managed/UnityEngine.dll"
transfer "Frameworks/MonoEmbedRuntime/osx/libmono.0.dylib"
transfer "Frameworks/MonoEmbedRuntime/osx/libMonoPosixHelper.dylib"
transfer "MacOS/UnityPlayer" "MacOS/KSP"
@johndalton
Copy link
Author

@lamont-granquist
Copy link

^ for bonus points you shouldn't run the backup mv twice if the destination file already exists so that if you run the script twice it doesn't overwrite the backed up files.

should also probably use \mv and \cp` to bypass aliases and be explicit about your preferences for -i and -f arguments... (mv -i would be one way to avoid overwriting, but that being the default behavior of the shell is dependent upon the user's aliases).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment