-
Notifications
You must be signed in to change notification settings - Fork 32
Conversation
return $_out; | ||
} | ||
|
||
return $_out = 'no' !== Processus::execute('echo ${TMUX:-"no"}', false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why doing a shell-out here instead of something like:
$tmux = getenv('TMUX');
return $tmux !== '' && $tmux !== false;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree… Maybe isset($_SERVER['TMUX'])
is even better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Sometimes this is useful to know whether we are running behind TMUX(1) or not. For instance, some control sequences are not supported by TMUX(1) yet and we have to apply some specific strategies. Because TMUX(1) is very popular, we allow ourselves such an approach.
Refering to http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324, we learn there is a special form to by-pass TMUX(1) and send control sequences to the upper terminal. We have to use the: \033Ptmux;…\033\\ control sequence where `…` is the original control sequence where `\033` are doubled.
@jubianchi Fixed. |
@Hywan perhaps this is out of scope but let ask it anyway :) Wouldn't it make sense to also do the same for It seems we can check if we are in a screen session by checking for |
@jubianchi Maybe yes. I have to test everything on SCREEN(1) too. This is hard to do testing here :-/. With #54, this is going to be much better: For a specific tmux file, we will be able to test all the cursor, window etc. APIs, but I don't know how to test with TMUX(1). Yes we can still emulate TMUX(1) and re-run all the test suites, but we are not sure this is how TMUX(1) will work in practise. |
@Hywan this was just an idea :) Perhaps we should just keep this comment as a reminder ;) |
@Hywan I can't get this work even on iTerm2 (2.1.1) within tmux or simply running |
@jubianchi Please, open an issue as a reminder for screen :-). |
@jubianchi So first, the shell is not important. This is the responsibility of the terminal, so, what is the result of: $ hoa console:termcap -t Personally, I have
Here are the results for me:
Same results for both Bash and Zsh (normally it does not interfer). What are yours? |
@Hywan my results outside of tmux: $ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin14)
Copyright (C) 2007 Free Software Foundation, Inc.
$ vendor/bin/hoa console:termcap -t
$ export TERM=xterm-256color
$ vendor/bin/hoa console:termcap -t
xterm-256color
$ cat index.php
<?php
require_once __DIR__ . '/vendor/autoload.php';
var_dump(\Hoa\Console\Console::isTmuxRunning());
$ php index.php
bool(false)
$ cat index2.php
<?php
require_once __DIR__ . '/vendor/autoload.php';
Hoa\Console\Window::copy('foo' . uniqid());
$ php index2.php
$ pbpaste
previously copied string |
@jubianchi In iTerm2 preferences, in the General panel, do you have “Allow clipboard access to terminal apps” checked in the Selection section? |
@Hywan my bad! The checkbox was not checked: everything is ok now! Great feature 👍 |
Fiou, I was afraid! |
Maybe we have to notified this somewhere |
@Jir4 +1 : this should be documented somewhere |
Please, open an issue for that :-). |
Won't the shell command used to test |
[ -z "$TMUX" ] would check if |
Does no longer matter since we use the _SERVER PHP variable. Thanks! |
Fix #52.
Two steps (one more is required to get something clean, in another issue):
Console::isTmuxRunning
method,Window::copy
.To check whether TMUX(1) is running, we use the following Shell command (see Parameter expansion):
I first used
${TMUX?}
but it prints an error on stderr if the variable is not defined. This “trick” is still clean though.To add TMUX(1) support on
Window::copy
, we use information on this URL: http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324. We learn there is a special form to by-pass TMUX(1) and send control sequences to the upper terminal. We have to use the:control sequence where
…
is the original control sequence where\033
are doubled.This PR is ready to be reviewed.
The next step is to have a unified way to write on the output (so far we only do
echo
and it sucks sometimes, e.g. withWindow::copy
; it is only more difficult to embed, /cc @jubianchi). I am opening a new issue right now.I am assigning @jubianchi for the review.