linux中vim编辑sh文件,Ubuntu下编写SHELL实现右键用VIM打开指定文件

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

72eb410b7109eca0959670ac629b886e.png2cf455e4e505de344f3a9c1521b68974.png#!/bin/bash

# 这是一个通过Shell调用VI编辑器来打开

# 选定文件的脚本程序。

# 作者:望水

# Email:csauthor@gmail.com

# 个人网站:http://www.oscoder.cn

# 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" ];then

set $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS

if [ $# -eq 1 ];then

destination="$1"

if [ -f "$destination" ];then

destination="$1"

else

zenity --error --title="Error-Open Vi here"\

--text="You can only select a file that Vi supported!"

exit 1

fi

else

zenity --error --title="Error-Open Vi here"\

--text="Only select the one file."

exit 1

fi

fi

exec x-terminal-emulator -e vi "$destination"0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值