ubuntu14.04系统下,快捷键编译gedit生成的c++和c和java文件设置
gedit的配置 tool->tool manager
#!/bin/sh
fullname=$GEDIT_CURRENT_DOCUMENT_NAME #获取文件名
name=`echo $fullname | cut -d. -f1` #按照.字符将文件名切开,前面的给name变量
suffix=`echo $fullname | cut -d. -f2` #按照.字符将文件名切开,后面的给suffix变量
if [ $suffix = "c" ]; then
gcc $fullname -o $name && echo "build success"
elif [ $suffix = "cpp" ] || [ $suffix = "c++" ] || [ $suffix = "cc" ] || [ $suffix = "cxx" ] || [ $suffix = "C" ]; then
g++ $fullname -lpthread -o $name && echo "build success"
elif [ $suffix = "java" ]; then
javac $fullname -encoding UTF-8 -sourcepath . -d .
fi
dir=$GEDIT_CURRENT_DOCUMENT_DIR #doc文件所在目录
gnome-terminal --hide-menubar --working-directory=$dir -t " 终端-$name" -x bash -c "$dir/$name; echo;echo '按回车键返回';read"
#Ubuntu14.04系统下默认使用的终端,名字叫gnome-terminal
gnome-terminal介绍参考如下链接:http://blog.csdn.net/zong596568821xp/article/details/78623130
原文链接:https://www.f2er.com/ubuntu/350434.html