Permalink
Browse files

add csh style env arguments for completion's sake

  • Loading branch information...
1 parent c0e2c97 commit a0f07eca1a4f605cf9d45f7ead211ea72627b0e5 @vodik committed Nov 25, 2013
Showing with 20 additions and 1 deletion.
  1. +1 −0 README.md
  2. +1 −0 _envoy
  3. +16 −1 envoy.c
  4. +2 −0 man/envoy.1
View
@@ -51,6 +51,7 @@ configuration.
-u, --unlock=[PASS] unlock the agent's keyring (gpg-agent only)
-p, --print print out environmental arguments
-s, --sh print sh style commands
+ -c, --csh print csh style commands
-f, --fish print fish style commands
-t, --agent=AGENT set the prefered to start
View
@@ -14,6 +14,7 @@ envoy)
{-u,--unlock=-}'[unlock the agent''s keyring (gpg-agent only)]'\
{-p,--print}'[print out environmental arguments]' \
{-s,--sh}'[print sh style commands]' \
+ {-c,--csh}'[print csh style commands]' \
{-f,--fish}'[print fish style commands]' \
{-t,--agent=-}'[set the prefered to start]:agents:(ssh-agent gpg-agent)'
;;
View
@@ -146,6 +146,15 @@ static void print_sh_env(struct agent_data_t *data)
printf("export SSH_AGENT_PID='%d'\n", data->pid);
}
+static void print_csh_env(struct agent_data_t *data)
+{
+ if (data->type == AGENT_GPG_AGENT)
+ printf("setenv GPG_AGENT_INFO %s;\n", data->gpg);
+
+ printf("setenv SSH_AUTH_SOCK %s;\n", data->sock);
+ printf("setenv SSH_AGENT_PID %d;\n", data->pid);
+}
+
static void print_fish_env(struct agent_data_t *data)
{
if (data->type == AGENT_GPG_AGENT)
@@ -200,6 +209,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
" -u, --unlock=[PASS] unlock the agent's keyring (gpg-agent only)\n"
" -p, --print print out environmental arguments\n"
" -s, --sh print sh style commands\n"
+ " -c, --csh print csh style commands\n"
" -f, --fish print fish style commands\n"
" -t, --agent=AGENT set the prefered to start\n", out);
@@ -224,13 +234,15 @@ int main(int argc, char *argv[])
{ "list", no_argument, 0, 'l' },
{ "unlock", optional_argument, 0, 'u' },
{ "print", no_argument, 0, 'p' },
+ { "sh", no_argument, 0, 's' },
+ { "csh", no_argument, 0, 'c' },
{ "fish", no_argument, 0, 'f' },
{ "agent", required_argument, 0, 't' },
{ 0, 0, 0, 0 }
};
while (true) {
- int opt = getopt_long(argc, argv, "hvakKlu::psft:", opts, NULL);
+ int opt = getopt_long(argc, argv, "hvakKlu::pscft:", opts, NULL);
if (opt == -1)
break;
@@ -265,6 +277,9 @@ int main(int argc, char *argv[])
case 's':
print_env = print_sh_env;
break;
+ case 'c':
+ print_env = print_csh_env;
+ break;
case 'f':
print_env = print_fish_env;
break;
View
@@ -48,6 +48,8 @@ Print out the environmental variables associated with the running agent.
Useful for injecting these variables into the shell.
.IP "\fB\-s\fR, \fB\-\-sh\fR"
Print sh-style commands when outputting environmental variables.
+.IP "\fB\-c\fR, \fB\-\-csh\fR"
+Print csh-style commands when outputting environmental variables.
.IP "\fB\-f\fR, \fB\-\-fish\fR"
Print fish-style commands when outputting environmental variables.
.IP "\fB\-t\fR \fIAGENT\fR, \fB\-\-agent\fR\fB=\fR\fIAGENT\fR

0 comments on commit a0f07ec

Please sign in to comment.