mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	Accept an argument to show-environment to show one variable, based on a
diff from Kazuhiko Sakaguchi.
This commit is contained in:
		@@ -31,8 +31,8 @@ int	cmd_show_environment_exec(struct cmd *, struct cmd_ctx *);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const struct cmd_entry cmd_show_environment_entry = {
 | 
					const struct cmd_entry cmd_show_environment_entry = {
 | 
				
			||||||
	"show-environment", "showenv",
 | 
						"show-environment", "showenv",
 | 
				
			||||||
	"gt:", 0, 0,
 | 
						"gt:", 0, 1,
 | 
				
			||||||
	"[-g] " CMD_TARGET_SESSION_USAGE,
 | 
						"[-g] " CMD_TARGET_SESSION_USAGE " [name]",
 | 
				
			||||||
	0,
 | 
						0,
 | 
				
			||||||
	NULL,
 | 
						NULL,
 | 
				
			||||||
	NULL,
 | 
						NULL,
 | 
				
			||||||
@@ -55,6 +55,19 @@ cmd_show_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
 | 
				
			|||||||
		env = &s->environ;
 | 
							env = &s->environ;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (args->argc != 0) {
 | 
				
			||||||
 | 
							envent = environ_find(env, args->argv[0]);
 | 
				
			||||||
 | 
							if (envent == NULL) {
 | 
				
			||||||
 | 
								ctx->error(ctx, "unknown variable: %s", args->argv[0]);
 | 
				
			||||||
 | 
								return (-1);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (envent->value != NULL)
 | 
				
			||||||
 | 
								ctx->print(ctx, "%s=%s", envent->name, envent->value);
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								ctx->print(ctx, "-%s", envent->name);
 | 
				
			||||||
 | 
							return (0);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	RB_FOREACH(envent, environ, env) {
 | 
						RB_FOREACH(envent, environ, env) {
 | 
				
			||||||
		if (envent->value != NULL)
 | 
							if (envent->value != NULL)
 | 
				
			||||||
			ctx->print(ctx, "%s=%s", envent->name, envent->value);
 | 
								ctx->print(ctx, "%s=%s", envent->name, envent->value);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								tmux.1
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								tmux.1
									
									
									
									
									
								
							@@ -2908,12 +2908,16 @@ new process.
 | 
				
			|||||||
.It Xo Ic show-environment
 | 
					.It Xo Ic show-environment
 | 
				
			||||||
.Op Fl g
 | 
					.Op Fl g
 | 
				
			||||||
.Op Fl t Ar target-session
 | 
					.Op Fl t Ar target-session
 | 
				
			||||||
 | 
					.Op Ar variable
 | 
				
			||||||
.Xc
 | 
					.Xc
 | 
				
			||||||
.D1 (alias: Ic showenv )
 | 
					.D1 (alias: Ic showenv )
 | 
				
			||||||
Display the environment for
 | 
					Display the environment for
 | 
				
			||||||
.Ar target-session
 | 
					.Ar target-session
 | 
				
			||||||
or the global environment with
 | 
					or the global environment with
 | 
				
			||||||
.Fl g .
 | 
					.Fl g .
 | 
				
			||||||
 | 
					If
 | 
				
			||||||
 | 
					.Ar variable
 | 
				
			||||||
 | 
					is omitted, all variables are shown.
 | 
				
			||||||
Variables removed from the environment are prefixed with
 | 
					Variables removed from the environment are prefixed with
 | 
				
			||||||
.Ql - .
 | 
					.Ql - .
 | 
				
			||||||
.El
 | 
					.El
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user