たとえば、私は ~/Downloads にあり、このパスを使用して新しい端末を実行するスクリプトを実行したいと思います。
私は何をしました。仕事.sh
#! /bin/bash
current_path="$PWD"
echo $current_path | xclip -selection clipboard
xfce4-terminal -e "zsh -c 'cd ~/Documents/bash/bash-scripts; ./work-test.sh; zsh'"
Workingtest.sh
#! /bin/bash
script_path=$(xclip -o -selection clipboard)
echo $script_path
sleep 1
cd "$script_path"
スクリプトの実行
source ~/Documents/bash/bash-scripts/work.sh
しかし、働かないでください。
ベストアンサー1
xfce4-terminal
現在のディレクトリが新しいインスタンスに渡されました。
はい
# Terminal session 1
cd /tmp
xfce4-terminal &
# New terminal session 2
pwd
/tmp
# Back to terminal session 1
cd
xfce4-terminal &
# New terminal session 3
pwd
/home/chris
入力が多すぎると、xfce4-terminal &
関数やエイリアスの作成に干渉しません。たとえば、関数は次のように呼び出されます。xt
xt() { xfce4-terminal "$@" & }