Re: tmux: How to create a new window with the same path (from the current pane)

2019-12-07 Thread Atanas Vladimirov

On 2019-11-26 17:38, Anders Damsgaard wrote:

* Atanas Vladimirov  [2019-11-26 17:10:14 +0200]:

So, if I understand your example right, I need to do something like 
`bind c new-window -c "$PWD"` in my .tmux.conf.
The problem is that it works partially - if I'm in 
`/home//` and start tmux there,
the $PWD is correct, but when I change the directory and create a new 
window with `C-b c` it moves me to the initial $PWD (when the tmux was 
started)

instead of the current directory.


I don't bind in .tmux.conf, but you could do:

bind c send-keys "tmux new-window -c \"$(pwd)\"" C-m
bind C send-keys "tmux split-pane -c \"$(pwd)\"" C-m

but it needs a shell prompt in the currently active pane.

Cheers, Anders


Thanks Anders,
That works as it should :)



Re: tmux: How to create a new window with the same path (from the current pane)

2019-11-26 Thread Anders Damsgaard

* Atanas Vladimirov  [2019-11-26 17:10:14 +0200]:

So, if I understand your example right, I need to do something like 
`bind c new-window -c "$PWD"` in my .tmux.conf.
The problem is that it works partially - if I'm in 
`/home//` and start tmux there,
the $PWD is correct, but when I change the directory and create a new 
window with `C-b c` it moves me to the initial $PWD (when the tmux was 
started)

instead of the current directory.


I don't bind in .tmux.conf, but you could do:

bind c send-keys "tmux new-window -c \"$(pwd)\"" C-m
bind C send-keys "tmux split-pane -c \"$(pwd)\"" C-m

but it needs a shell prompt in the currently active pane.

Cheers, Anders



Re: tmux: How to create a new window with the same path (from the current pane)

2019-11-26 Thread Atanas Vladimirov

On 2019-11-26 16:27, Anders Damsgaard wrote:

* Atanas Vladimirov  [2019-11-26 14:27:33 +0200]:


Hello,

The following works on Linux:

```
bind c new-window -c "#{pane_current_path}"

```

but the `pane_current_path` variable does not exists on OpenBSD.
Does anyone now how can I achieve the same behavior on OpenBSD?


Hi Atanas,

I recently asked Nicolas Marriott the same question on Freenode/#tmux. 
The

pane_current_path functionality is disabled on OpenBSD because of
security reasons.

For that reason I added the following function to my ~/.profile.  
However,

it does not enable splitting without sending current processes to
background:

tsplit() {
if [ -z "$TMUX" ]; then
echo "error: not in tmux session" >&2
return 1
fi
if [ $# -gt 0 ]; then
if [ "$1" = "v" ]; then
tmux split-pane -v -c "$PWD"
elif [ "$1" = "h" ]; then
tmux split-pane -h -c "$PWD"
elif [ "$1" = "w" ]; then
tmux new-window -c "$PWD"
else
echo "error: split direction not understood" >&2
return 2
fi
else
tmux split-pane -h -c $PWD
fi
}

Best, Anders


Hi Anders,

Thanks for your reply.
So, if I understand your example right, I need to do something like 
`bind c new-window -c "$PWD"` in my .tmux.conf.
The problem is that it works partially - if I'm in 
`/home//` and start tmux there,
the $PWD is correct, but when I change the directory and create a new 
window with `C-b c` it moves me to the initial $PWD (when the tmux was 
started)

instead of the current directory.

Does anyone know how to make it work as I desire, or it's not possible?
Thanks in advance,
Atanas






Re: tmux: How to create a new window with the same path (from the current pane)

2019-11-26 Thread Anders Damsgaard

* Atanas Vladimirov  [2019-11-26 14:27:33 +0200]:


Hello,

The following works on Linux:

```
bind c new-window -c "#{pane_current_path}"

```

but the `pane_current_path` variable does not exists on OpenBSD.
Does anyone now how can I achieve the same behavior on OpenBSD?


Hi Atanas,

I recently asked Nicolas Marriott the same question on Freenode/#tmux. The
pane_current_path functionality is disabled on OpenBSD because of
security reasons.

For that reason I added the following function to my ~/.profile.  However,
it does not enable splitting without sending current processes to
background:

tsplit() {
if [ -z "$TMUX" ]; then
echo "error: not in tmux session" >&2
return 1
fi
if [ $# -gt 0 ]; then
if [ "$1" = "v" ]; then
tmux split-pane -v -c "$PWD"
elif [ "$1" = "h" ]; then
tmux split-pane -h -c "$PWD"
elif [ "$1" = "w" ]; then
tmux new-window -c "$PWD"
else
echo "error: split direction not understood" >&2
return 2
fi
else
tmux split-pane -h -c $PWD
fi
}

Best, Anders
--
Anders Damsgaard
https://adamsgaard.dk