Hi,
This patch add a -n argument to show-environment. It specifies a variable name.
example:
$ tmux show-environment -g -n TERM
rxvt-unicode-256color
--- a/cmd-show-environment.c
+++ b/cmd-show-environment.c
@@ -31,8 +31,8 @@ int cmd_show_environment_exec(struct cmd *, struct cmd_ctx
*);
const struct cmd_entry cmd_show_environment_entry = {
"show-environment", "showenv",
- "gt:", 0, 0,
- "[-g] " CMD_TARGET_SESSION_USAGE,
+ "gt:n:", 0, 0,
+ "[-g] " CMD_TARGET_SESSION_USAGE " [-n name]",
0,
NULL,
NULL,
@@ -46,6 +46,7 @@ cmd_show_environment_exec(struct cmd *self, struct
cmd_ctx *ctx)
struct session *s;
struct environ *env;
struct environ_entry *envent;
+ const char *name;
if (args_has(self->args, 'g'))
env = &global_environ;
@@ -55,11 +56,22 @@ cmd_show_environment_exec(struct cmd *self, struct
cmd_ctx *ctx)
env = &s->environ;
}
- RB_FOREACH(envent, environ, env) {
- if (envent->value != NULL)
- ctx->print(ctx, "%s=%s", envent->name, envent->value);
- else
- ctx->print(ctx, "-%s", envent->name);
+ name = args_get(self->args, 'n');
+ if (name != NULL){
+ envent = environ_find(env, name);
+ if (envent == NULL){
+ ctx->error(ctx, "entry not found");
+ return (-1);
+ }
+ ctx->print(ctx, envent->value);
+ }
+ else {
+ RB_FOREACH(envent, environ, env) {
+ if (envent->value != NULL)
+ ctx->print(ctx, "%s=%s", envent->name,
envent->value);
+ else
+ ctx->print(ctx, "-%s", envent->name);
+ }
}
return (0);
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
tmux-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-users