Closed Hywan closed 9 years ago
@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 screen
?
It seems we can check if we are in a screen session by checking for $STY
. We would then avec Console:: isTmuxRunning
and Console::isScreenRunning
.
@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 bash
(GNU bash, version 3.2.57(1)-release
and GNU bash, version 4.3.42(1)-release
) outside of tmux
@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 xterm-256color
.
Then, I also have iTerm2 (2.1.1) and tmux. Here is what we are going to try:
Outside tmux | Inside tmux | |
---|---|---|
Console\Console::isTmuxRunning() |
||
Console\Window::copy('foo' . uniqid()) |
Here are the results for me:
Outside tmux | Inside tmux | |
---|---|---|
Console\Console::isTmuxRunning() |
bool(false) |
bool(true) |
Console\Window::copy('foo' . uniqid()) |
$ pbpaste # foo60cd3c6159c3 |
$ pbpaste # foo560cd3c584044 |
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 :+1:
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 $TMUX be shell dependent though? The ${:-} stuff isn't universally supported afaik.
[ -z "$TMUX" ] would check if $TMUX is zero-length (empty or undefined) without requiring from the shell that ${:-} is understood.
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.