sh 在Linux上安装p4merge的脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 在Linux上安装p4merge的脚本相关的知识,希望对你有一定的参考价值。

#!/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"

以上是关于sh 在Linux上安装p4merge的脚本的主要内容,如果未能解决你的问题,请参考以下文章

sh 在Ubuntu Linux 14.04 LTS上安装ThingWorx Platform 7.4的安装脚本

sh Bash脚本在Linux上安装SiS Mirage 3+图形驱动程序

sh 在Linux和WSL上安装Go 1.8.3的脚本(适用于Linux的Windows子系统)

sh 此脚本在大多数Linux系统上从源代码下载并安装fish shell。

linux自动部署--sh脚本安装jdk,tomcat,mysqlclient

linux自动部署--sh脚本安装jdk,tomcat,mysqlclient