mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	has-session command.
This commit is contained in:
		
							
								
								
									
										6
									
								
								CHANGES
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								CHANGES
									
									
									
									
									
								
							@@ -1,3 +1,7 @@
 | 
			
		||||
25 October 2007
 | 
			
		||||
 | 
			
		||||
* (nicm) has-session command: checks if session exists.
 | 
			
		||||
 | 
			
		||||
24 October 2007
 | 
			
		||||
 | 
			
		||||
* (nicm) Support for \e6n to request cursor position. resize(1) now works.
 | 
			
		||||
@@ -159,5 +163,5 @@
 | 
			
		||||
  (including mutt, emacs). No status bar yet and no key remapping or other
 | 
			
		||||
  customisation.
 | 
			
		||||
 | 
			
		||||
$Id: CHANGES,v 1.50 2007-10-24 15:29:27 nicm Exp $
 | 
			
		||||
$Id: CHANGES,v 1.51 2007-10-25 17:44:24 nicm Exp $
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								Makefile
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
# $Id: Makefile,v 1.30 2007-10-23 09:36:19 nicm Exp $
 | 
			
		||||
# $Id: Makefile,v 1.31 2007-10-25 17:44:24 nicm Exp $
 | 
			
		||||
 | 
			
		||||
.SUFFIXES: .c .o .y .h
 | 
			
		||||
.PHONY: clean
 | 
			
		||||
@@ -23,7 +23,8 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
 | 
			
		||||
      cmd-unbind-key.c cmd-previous-window.c cmd-last-window.c cmd-list-keys.c \
 | 
			
		||||
      cmd-set-option.c cmd-rename-window.c cmd-select-window.c \
 | 
			
		||||
      cmd-list-windows.c cmd-attach-session.c cmd-send-prefix.c \
 | 
			
		||||
      cmd-refresh-session.c cmd-kill-window.c cmd-list-clients.c
 | 
			
		||||
      cmd-refresh-session.c cmd-kill-window.c cmd-list-clients.c \
 | 
			
		||||
      cmd-has-session.c
 | 
			
		||||
 | 
			
		||||
YACC= yacc -d
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								TODO
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								TODO
									
									
									
									
									
								
							@@ -43,7 +43,6 @@
 | 
			
		||||
  kill-window to limit accidental presses
 | 
			
		||||
- status-fg/status-bg should be to set attributes: bold, etc
 | 
			
		||||
- show-options command
 | 
			
		||||
- fix resize(1)
 | 
			
		||||
- detach client and other client commands. note that there can only be a
 | 
			
		||||
  "current client" on key presses - these should act like detach-session -
 | 
			
		||||
  -a will do all clients, otherwise do nothing unless key in which case do
 | 
			
		||||
@@ -51,6 +50,7 @@
 | 
			
		||||
- check handling of out-of-bound values in input.c, most should be limited
 | 
			
		||||
  rather than ignored
 | 
			
		||||
- save/restore (DECSC/DECRC) are ugly. maybe a struct screen_attr and memcpy
 | 
			
		||||
- force maximum terminal size (centred?)
 | 
			
		||||
 | 
			
		||||
-- For 0.1 --------------------------------------------------------------------
 | 
			
		||||
- man page
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										51
									
								
								cmd-has-session.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								cmd-has-session.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,51 @@
 | 
			
		||||
/* $Id: cmd-has-session.c,v 1.1 2007-10-25 17:44:24 nicm Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
 *
 | 
			
		||||
 * Permission to use, copy, modify, and distribute this software for any
 | 
			
		||||
 * purpose with or without fee is hereby granted, provided that the above
 | 
			
		||||
 * copyright notice and this permission notice appear in all copies.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 | 
			
		||||
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 | 
			
		||||
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 | 
			
		||||
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 | 
			
		||||
 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
 | 
			
		||||
 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
 | 
			
		||||
#include <getopt.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#include "tmux.h"
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Cause client to exit with 0 if session exists, or 1 if it doesn't. This
 | 
			
		||||
 * is handled in the caller since this doesn't have flag CMD_NOSESSION, so
 | 
			
		||||
 * all that is necessary is to exit.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
void	cmd_has_session_exec(void *, struct cmd_ctx *);
 | 
			
		||||
 | 
			
		||||
const struct cmd_entry cmd_has_session_entry = {
 | 
			
		||||
	"has-session", "has", "",
 | 
			
		||||
	0,
 | 
			
		||||
	NULL,
 | 
			
		||||
	cmd_has_session_exec,
 | 
			
		||||
	NULL,
 | 
			
		||||
	NULL,
 | 
			
		||||
	NULL
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
cmd_has_session_exec(unused void *ptr, struct cmd_ctx *ctx)
 | 
			
		||||
{
 | 
			
		||||
	struct client	*c = ctx->client;
 | 
			
		||||
	
 | 
			
		||||
	if (!(ctx->flags & CMD_KEY))
 | 
			
		||||
		server_write_client(c, MSG_EXIT, NULL, 0);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										3
									
								
								cmd.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								cmd.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: cmd.c,v 1.19 2007-10-23 09:36:19 nicm Exp $ */
 | 
			
		||||
/* $Id: cmd.c,v 1.20 2007-10-25 17:44:24 nicm Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -27,6 +27,7 @@ const struct cmd_entry *cmd_table[] = {
 | 
			
		||||
	&cmd_attach_session_entry,
 | 
			
		||||
	&cmd_bind_key_entry,
 | 
			
		||||
	&cmd_detach_session_entry,
 | 
			
		||||
	&cmd_has_session_entry,
 | 
			
		||||
	&cmd_kill_window_entry,
 | 
			
		||||
	&cmd_last_window_entry,
 | 
			
		||||
	&cmd_list_clients_entry,
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@ SESSION=natasha-main
 | 
			
		||||
 | 
			
		||||
TMUX="tmux -S $SOCKET"
 | 
			
		||||
 | 
			
		||||
if ! $TMUX -s $SESSION attach 2>/dev/null; then
 | 
			
		||||
if ! $TMUX -s $SESSION has 2>/dev/null; then
 | 
			
		||||
    $TMUX new -d -s $SESSION -nyelena 'exec ssh yelena'		# 0
 | 
			
		||||
 | 
			
		||||
    $TMUX set default-command "$SHELL -l"
 | 
			
		||||
@@ -27,6 +27,6 @@ if ! $TMUX -s $SESSION attach 2>/dev/null; then
 | 
			
		||||
    $TMUX bind ^A send-prefix
 | 
			
		||||
 | 
			
		||||
    $TMUX set bell-action none
 | 
			
		||||
 | 
			
		||||
    $TMUX -s $SESSION attach
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
$TMUX -s $SESSION attach
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: tmux.h,v 1.69 2007-10-24 15:40:59 nicm Exp $ */
 | 
			
		||||
/* $Id: tmux.h,v 1.70 2007-10-25 17:44:24 nicm Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -531,6 +531,7 @@ char		*cmd_recv_string(struct buffer *);
 | 
			
		||||
extern const struct cmd_entry cmd_attach_session_entry;
 | 
			
		||||
extern const struct cmd_entry cmd_bind_key_entry;
 | 
			
		||||
extern const struct cmd_entry cmd_detach_session_entry;
 | 
			
		||||
extern const struct cmd_entry cmd_has_session_entry;
 | 
			
		||||
extern const struct cmd_entry cmd_kill_window_entry;
 | 
			
		||||
extern const struct cmd_entry cmd_last_window_entry;
 | 
			
		||||
extern const struct cmd_entry cmd_list_clients_entry;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user