Created
May 6, 2016 22:00
-
-
Save smac89/4d09c0661f2b30c332f48a7fc4d8bb24 to your computer and use it in GitHub Desktop.
Script to install p4merge on Linux
This file contains 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
#!/bin/bash | |
set -euf | |
if [[ ! "$#" = 1 ]]; then | |
echo "You need to supply the folder containing p4merge as arguement" | |
exit 1 | |
elif [[ ! -d "$1" ]]; then | |
echo "The file is not a folder" | |
exit 1 | |
elif [[ ! "$(find $1 -type f | grep p4merge)" ]]; then | |
echo "The folder does not contain p4merge" | |
exit 1 | |
fi | |
[[ $EUID -eq 0 ]] && dest='/opt/p4merge' || dest="$HOME/p4merge" | |
[[ $EUID -eq 0 ]] && lnk='/usr/local/bin' || lnk="$HOME/bin" | |
# remove the destination folder if it exists | |
rm -rf "$dest" | |
# Create the directory | |
mkdir -p "$dest" | |
mkdir -p "$lnk" | |
# copy the files to the new directory | |
cp -r "$1/." "$dest" | |
# Create a link to the tool and put it somewhere accessible | |
ln -sf "$dest/bin/p4merge" "$lnk/p4merge" | |
if [[ ! "$(echo $PATH | grep "$lnk")" ]]; then | |
echo "Add the following to your .profile or .bash_profile" | |
echo 'export PATH='"$lnk"':"$PATH"' | |
fi | |
echo -e 'Run the following commands to configure git to use p4merge:\n' | |
echo 'git config --global merge.tool p4merge' | |
echo 'git config --global mergetool.prompt false' | |
echo 'git config --global mergetool.p4merge.path'" $lnk/p4merge" | |
echo 'git config --global diff.tool p4merge' | |
echo 'git config --global difftool.prompt false' | |
echo 'git config --global difftool.p4merge.path'" $lnk/p4merge" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment