From 884c22f0c69a1454de8e66ccc983b64283e4aef2 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 20 May 2008 23:07:39 -0700 Subject: [PATCH] change --clean be the default and add --bash to duplicate old method --- bti.1 | 8 ++++---- bti.c | 22 ++++++++++++---------- bti.xml | 12 ++++++++---- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/bti.1 b/bti.1 index 4727a97..7e4fed7 100644 --- a/bti.1 +++ b/bti.1 @@ -14,7 +14,7 @@ bti - send a tweet to twitter.com from the command line .SH "SYNOPSIS" .HP 4 -\fBbti\fR [\fB\-\-account\ account\fR] [\fB\-\-password\ password\fR] [\fB\-\-clean\fR] [\fB\-\-debug\fR] [\fB\-\-version\fR] [\fB\-\-help\fR] +\fBbti\fR [\fB\-\-account\ account\fR] [\fB\-\-password\ password\fR] [\fB\-\-bash\fR] [\fB\-\-debug\fR] [\fB\-\-version\fR] [\fB\-\-help\fR] .SH "DESCRIPTION" .PP bti sends a twitter message to twitter\.com\. @@ -35,9 +35,9 @@ Specify the password of your twitter\.com account\. Print a whole bunch of debugging messages to stdout\. .RE .PP -\fB\-\-clean\fR +\fB\-\-bash\fR .RS 4 -Don\'t put the working directory and the \'$\' in the twitter message\. +Add the working directory and a \'$\' in the twitter message to help specify it is coming from a command line\. Don\'t put the working directory and the \'$\' in the twitter message\. .RE .PP \fB\-\-version\fR @@ -58,7 +58,7 @@ It\'s primary focus is to allow you to log everything that you type into a bash To hook bti up to your bash shell, export the following variable: .PP -PROMPT_COMMAND=\'history 1 | sed \-e "s/^\es*[0\-9]*\es*//" | bti\' +PROMPT_COMMAND=\'history 1 | sed \-e "s/^\es*[0\-9]*\es*//" | bti \-\-bash\' .PP This example assumes that you have the \fI~/\.bti\fR diff --git a/bti.c b/bti.c index 7baf337..bf6a809 100644 --- a/bti.c +++ b/bti.c @@ -44,7 +44,7 @@ struct session { char *password; char *account; char *tweet; - int clean; + int bash; }; struct bti_curl_buffer { @@ -61,7 +61,7 @@ static void display_help(void) fprintf(stdout, "options are:\n"); fprintf(stdout, " --account accountname\n"); fprintf(stdout, " --password password\n"); - fprintf(stdout, " --clean\n"); + fprintf(stdout, " --bash\n"); fprintf(stdout, " --debug\n"); fprintf(stdout, " --version\n"); fprintf(stdout, " --help\n"); @@ -299,7 +299,7 @@ int main(int argc, char *argv[], char *envp[]) { "account", 1, NULL, 'a' }, { "password", 1, NULL, 'p' }, { "help", 0, NULL, 'h' }, - { "clean", 0, NULL, 'c' }, + { "bash", 0, NULL, 'b' }, { "version", 0, NULL, 'v' }, { } }; @@ -342,8 +342,8 @@ int main(int argc, char *argv[], char *envp[]) session->password = strdup(optarg); dbg("password = %s\n", session->password); break; - case 'c': - session->clean = 1; + case 'b': + session->bash= 1; break; case 'h': display_help(); @@ -367,6 +367,7 @@ int main(int argc, char *argv[], char *envp[]) session->password = get_string_from_stdin(); } + /* get the current working directory basename */ if (strcmp(pwd, home) == 0) dir = "~"; else { @@ -377,8 +378,6 @@ int main(int argc, char *argv[], char *envp[]) dir = "?"; } - /* Add the "PWD $ " to the start of the tweet to show it is - * coming from a shell unless --clean is specified. */ tweet = get_string_from_stdin(); if (strlen(tweet) == 0) { dbg("no tweet?\n"); @@ -386,10 +385,13 @@ int main(int argc, char *argv[], char *envp[]) } session->tweet = zalloc(strlen(tweet) + strlen(dir) + 10); - if (session->clean) - sprintf(session->tweet, "%s", tweet); - else + + /* if --bash is specified, add the "PWD $ " to + * the start of the tweet. */ + if (session->bash) sprintf(session->tweet, "%s $ %s", dir, tweet); + else + sprintf(session->tweet, "%s", tweet); free(tweet); dbg("account = %s\n", session->account); diff --git a/bti.xml b/bti.xml index 75c9dd9..908cb26 100644 --- a/bti.xml +++ b/bti.xml @@ -28,7 +28,7 @@ bti - + @@ -65,9 +65,13 @@ - + - Don't put the working directory and the '$' in the twitter message. + + Add the working directory and a '$' in the twitter message to + help specify it is coming from a command line. Don't put the + working directory and the '$' in the twitter message. + @@ -105,7 +109,7 @@ To hook bti up to your bash shell, export the following variable: - PROMPT_COMMAND='history 1 | sed -e "s/^\s*[0-9]*\s*//" | bti' + PROMPT_COMMAND='history 1 | sed -e "s/^\s*[0-9]*\s*//" | bti --bash' This example assumes that you have the -- 2.39.5