Welcome 微信登录

首页 / 操作系统 / Linux / Ubuntu下编写SHELL实现右键用VIM打开指定文件

这时间放假,闲在家里无聊,所以,每天就看看书,写写程序,,,,当然,,在我的Ubuntu 9.10下,我还是列喜欢那个VIM,,,支持一些快捷的操作和可以运行一些外部命令。不过呢,在选择编辑某个文件时,却用VIM打开是个麻烦,每次先开一个终端,然后进入文件目录下。。。后来,自然而然的就想到把打开某个文件的指令加到右键菜单当中。。。我写了个SHELL,当然这个SHELL很简单,没用到与此正则,也没有太多的指令。如下:
#!/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" ];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"
  • 1
  • 2
  • 下一页
编写xorg.conf 简单三行解决Ubuntu分辩率不可调的问题解决Ubuntu Openbox无法启动的问题相关资讯      shell  Vim  Ubuntu教程 
  • 交叉编译Vim并移植到ARM嵌入式  (今 21:40)
  • 把Vim打造成优秀的C++ IDE  (06月13日)
  • Linux Vi/Vim 的使用及实例  (06月04日)
  • Vim 和 Emacs 到底哪个更适合你?  (07月25日)
  • 简明 Vim 练级攻略  (06月05日)
  • Vim 8.0 即将发布  (04月14日)
本文评论 查看全部评论 (0)
表情: 姓名: 字数