相比于windows的图形方式,ubuntu的命令行显得简单很多,但是每次需要打开命令行去寻找路径,打开应用程序还是不方便。
以下使用python写了一个小脚本,方便启动常用的工具,初学python,还请多指教,hehe。
#coding=utf-8
#!/usr/bin/python
# start.py
import sys
import os
commandDict = {
"idea" : "/home/cwz/tools/idea-IU-129.1525/bin/idea.sh",
"eclipse":"/home/cwz/tools/eclipse/eclipse",
"genymotion":"/home/cwz/VirtualBox\ VMs/genymotion/genymotion/genymotion"
}
# 判断用户是否输入了参数
if len(sys.argv) <= 1 :
print '请输入要打开的程序简称'
print 'python start.py -help for help'
exit()
# 判断用户输入-help时,输出所有可执行的命令
if sys.argv[1].startswith('-'):
option = sys.argv[1][1:]
if option == 'help' :
print '------------------command dict start-----------------------'
for command in commandDict:
print command,':',commandDict.get(command)
print '------------------command dict end-------------------------'
# 打开应用程序
if commandDict.has_key(sys.argv[1]):
os.system(commandDict.get(sys.argv[1]))