2012-04-06 220 views
1

我已经写了一个简单的bash脚本,提示输入文件或目录路径并打开它与外开放,然后我分配脚本到键盘快捷方式让我可以CTRL + SHIFT + ALT +Ø通过终端迅速打开随时事情:exo-open在终端脚本 - 程序关闭终端

The keyboard binding

和脚本:

#!/bin/bash 

# CD to the home folder (not sure if this is needed, no harm either way) 
cd ~/ 

# Request the filepath 
echo -e "\e[1;31mEnter a file or directory:\e[00m" 
read -e -i "~/" filename 

# Convert ~/ to /home/username/ 
filename=`eval "echo $filename"` 
echo -e "opening\e[1;32m" $filename "\e[00m" 

# Open the file 
exo-open "$filename" 

echo "press enter to exit" 
read enter 

我的问题是,在衍生程序链接到终端,当终端关闭所花费的程序与它 - 作为一个简单的解决方法我在最后给其他用户提示停止终端关闭;有谁知道我可以如何让终端关闭,但保持结果程序打开?

一些想法我有/试过:

  • 运行disown $!后外开(没有工作)
  • 使用nohup(没有工作)从
  • 运行外开在PPID(不知道如何做到这一点)

在我无计可施:-(

+0

不认取作业ID,所以用'%1',而不是'$! ' – 2012-04-06 13:42:32

+0

有趣的是,这给了我一个“无法执行默认终端模拟器。输入/输出错误“警告,我刚刚用'setsid exo-open”$ filename“'解决了它 – oodavid 2012-04-06 13:54:43

回答

1

我有这个ANSW通过Xfce的论坛成员的ToC

http://forum.xfce.org/viewtopic.php?pid=25670

ERED原来可以使用setsid像这样:

#!/bin/bash 

# CD to the home folder (not sure if this is needed, no harm either way) 
cd ~/ 

# Request the filepath 
echo -e "\e[1;31mEnter a file or directory:\e[00m" 
read -e -i "~/" filename 

# Convert ~/ to /home/username/ 
filename=`eval "echo $filename"` 
echo -e "opening\e[1;32m" $filename "\e[00m" 

# Open the file 
setsid exo-open "$filename"