注意:这个答案涵盖了IntelliJ IDEA的安装。有关涵盖更多 JetBrains IDE 的扩展脚本,以及字体呈现问题的帮助,请参阅 brendan 提供的此链接。
此外,手动创建桌面条目是可选的,因为较新版本的IntelliJ提供在首次启动时创建它。
我有我的intellij int /opt文件夹。所以我做的是:
- 下载 Intellij
- 将 intellij 解压缩到 /opt-folder:(-C 选项将 tar 解压缩到文件夹 /opt/)
sudo tar -xvf <intellij.tar> -C /opt/
- 创建一个名为idea.desktop的桌面条目文件(请参阅下面的示例文件),并将其存储在所需的任何位置(让我们假设在您的主目录中)
- 将 idea.desktop 从您的主目录移动到 /usr/share/applications:
sudo mv ~/idea.desktop /usr/share/applications/
现在(很多)Ubuntu版本,您可以在GUI重新启动后启动应用程序。如果你不知道如何执行此操作,可以重新启动电脑。
idea.desktop(这是针对社区版 14.1.2,如果路径不同,则必须更改 Exec= 和 Icon= 行中的路径):
[Desktop Entry]
Encoding=UTF-8
Name=IntelliJ IDEA
Comment=IntelliJ IDEA
Exec=/opt/ideaIC-14.1.2/bin/idea.sh
Icon=/opt/ideaIC-14.1.2/bin/idea.png
Terminal=false
StartupNotify=true
Type=Application
编辑
我还在这里找到了一个为你做这件事的shell脚本。链接中的给定脚本为您安装Oracle Java 7,并让您在社区版和终极版之间进行选择。然后,它会自动为您下载最新版本,将其解压缩并创建桌面条目。
我已经修改了脚本以满足我的需求。它不安装java 8,也不会要求您提供要安装的版本(但该版本保留在变量中以轻松更改)。您也可以使用它更新Intellij。但是,您必须(到目前为止)手动删除旧文件夹!这就是我得到的:
Edit2
这是脚本的新版本。正如评论中提到的,breandan已经更新了脚本,使其更加稳定(jetbrains网站改变了它的行为)。感谢您的更新,布雷安丹。
#!/bin/sh
echo "Installing IntelliJ IDEA..."
# We need root to install
[ $(id -u) != "0" ] && exec sudo "$0" "$@"
# Attempt to install a JDK
# apt-get install openjdk-8-jdk
# add-apt-repository ppa:webupd8team/java && apt-get update && apt-get install oracle-java8-installer
# Prompt for edition
#while true; do
# read -p "Enter 'U' for Ultimate or 'C' for Community: " ed
# case $ed in
# [Uu]* ) ed=U; break;;
# [Cc]* ) ed=C; break;;
# esac
#done
ed=C
# Fetch the most recent version
VERSION=$(wget "https://www.jetbrains.com/intellij-repository/releases" -qO- | grep -P -o -m 1 "(?<=https://www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/BUILD/)[^/]+(?=/)")
# Prepend base URL for download
URL="https://download.jetbrains.com/idea/ideaI$ed-$VERSION.tar.gz"
echo $URL
# Truncate filename
FILE=$(basename ${URL})
# Set download directory
DEST=~/Downloads/$FILE
echo "Downloading idea-I$ed-$VERSION to $DEST..."
# Download binary
wget -cO ${DEST} ${URL} --read-timeout=5 --tries=0
echo "Download complete!"
# Set directory name
DIR="/opt/idea-I$ed-$VERSION"
echo "Installing to $DIR"
# Untar file
if mkdir ${DIR}; then
tar -xzf ${DEST} -C ${DIR} --strip-components=1
fi
# Grab executable folder
BIN="$DIR/bin"
# Add permissions to install directory
chmod -R +rwx ${DIR}
# Set desktop shortcut path
DESK=/usr/share/applications/IDEA.desktop
# Add desktop shortcut
echo -e "[Desktop Entry]\nEncoding=UTF-8\nName=IntelliJ IDEA\nComment=IntelliJ IDEA\nExec=${BIN}/idea.sh\nIcon=${BIN}/idea.png\nTerminal=false\nStartupNotify=true\nType=Application" -e > ${DESK}
# Create symlink entry
ln -s ${BIN}/idea.sh /usr/local/bin/idea
echo "Done."
旧版本
#!/bin/sh
echo "Installing IntelliJ IDEA..."
# We need root to install
[ $(id -u) != "0" ] && exec sudo "$0" "$@"
# define version (ultimate. change to 'C' for Community)
ed='U'
# Fetch the most recent community edition URL
URL=$(wget "https://www.jetbrains.com/idea/download/download_thanks.jsp?edition=I${ed}&os=linux" -qO- | grep -o -m 1 "https://download.jetbrains.com/idea/.*gz")
echo "URL: ${URL}"
echo "basename(url): $(basename ${URL})"
# Truncate filename
FILE=$(basename ${URL})
echo "File: ${FILE}"
# Download binary
wget -cO /tmp/${FILE} ${URL} --read-timeout=5 --tries=0
# Set directory name
DIR="${FILE%\.tar\.gz}"
# Untar file
if mkdir /opt/${DIR}; then
tar -xvzf /tmp/${FILE} -C /opt/${DIR} --strip-components=1
fi
# Grab executable folder
BIN="/opt/$DIR/bin"
# Add permissions to install directory
chmod 755 ${BIN}/idea.sh
# Set desktop shortcut path
DESK=/usr/share/applications/IDEA.desktop
# Add desktop shortcut
echo -e "[Desktop Entry]\nEncoding=UTF-8\nName=IntelliJ IDEA\nComment=IntelliJ IDEA\nExec=${BIN}/idea.sh\nIcon=${BIN}/idea.png\nTerminal=false\nStartupNotify=true\nType=Application" > ${DESK}
echo "Done."