1

I am using zsh For example, i am in ~/Downloads, and want to run script, that will run new terminal with this path.

What i did. work.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'"

work-test.sh

#! /bin/bash

script_path=$(xclip -o -selection clipboard)
echo $script_path
sleep 1
cd "$script_path" 


Run script with

source ~/Documents/bash/bash-scripts/work.sh

But don't work.

0

1 Answer 1

3

xfce4-terminal already carries the current directory through to a new instance.

Example

# 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

If typing xfce4-terminal & is too much there's nothing stopping you creating a function or alias. For example, this function is invoked as xt

xt() { xfce4-terminal "$@" & }

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.