Ubuntu下编写SHELL实现右键用VIM打开指定文件

这时间放假,闲在家里无聊,,所以,每天就看看书,写写程序,,,,当然,,在我的Ubuntu 9.10下,我还是列喜欢那个VIM,,,支持一些快捷的操作和可以运行一些外部命令。不过呢,在选择编辑某个文件时,却用VIM打开是个麻烦,每次先开一个终端,然后进入文件目录下。。。后来,自然而然的就想到把打开某个文件的指令加到右键菜单当中。。。我写了个SHELL,当然这个SHELL很简单,没用到与此正则,也没有太多的指令。如下:

#!/bin/bash# 这是一个通过Shell调用VI编辑器来打开# 选定文件的脚本程序。# 作者:望水# Email:csauthor@gmail.com# 个人网站:# Distributed under the terms of GNU GPL version2 or later## install in ~/.gnome2/nautilus-scripts or ~/Nautilus/scripts# You need to be running Nautilus 1.0.3+ to use scripts.# When a directory is selected, go there. Otherwise go to current# directory. If more than one directory is selected, show error.if [ -n “$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS” ];thenset $NAUTILUS_SCRIPT_SELECTED_FILE_PATHSif [ $# -eq 1 ];thendestination=”$1″if [ -f “$destination” ];thendestination=”$1″elsezenity –error –title=”Error-Open Vi here”\–text=”You can only select a file that Vi supported!”exit 1fielsezenity –error –title=”Error-Open Vi here”\–text=”Only select the one file.”exit 1fifiexec x-terminal-emulator -e vi “$destination”

最困难之时,就是我们离成功不远之日。

Ubuntu下编写SHELL实现右键用VIM打开指定文件

相关文章:

你感兴趣的文章:

标签云: