2012-04-06 50 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"