{"thread":{"id":"871","subject":"[PATCH] Add support reading default options from conf file","startedAt":"2005-06-09T01:00:56Z","lastAt":"2005-06-11T01:09:31Z","messageCount":3,"participants":["Jonas Fonseca","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"4740","messageId":"20050609010056.GA9084@diku.dk","threadId":"871","inReplyTo":null,"subject":"[PATCH] Add support reading default options from conf file","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-06-09T01:00:56Z","receivedAt":"2005-06-09T01:00:56Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Reply-To: \nIn-Reply-To: <42A754D5.10705@gmail.com>\n\nDan Holmsand <holmsand@gmail.com> wrote Wed, Jun 08, 2005:\n> - Automatic color if the COGITO_AUTO_COLOR environment variable is set.\n\n[ This has been discussed before. Default arguments. The 'new' cg\n  wrapper makes this very easy. Not as smart as your env variable\n  handling tho'. ]\n\nThe default options are read only for Cogito calls going through the new\ncg wrapper which makes it trivial to 'overwrite' them by just calling\ncg-COMMAMD.\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n---\n\n Documentation/make-cogito-asciidoc |   12 ++++++++++++\n cg                                 |    6 +++++-\n 2 files changed, 17 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/make-cogito-asciidoc b/Documentation/make-cogito-asciidoc\n--- a/Documentation/make-cogito-asciidoc\n+++ b/Documentation/make-cogito-asciidoc\n@@ -140,6 +140,18 @@ FILE::\n \tIndicates an already existing filename - always relative to the root\n \tof the repository.\n \n+FILES\n+-----\n+~/.cogito.conf::\n+\tThis file is read when running the \\`cg\\` wrapper program and\n+\tcontains information about default options. Each line consists\n+\tof a command name and a list of options. Empty lines and lines\n+\tstarting with '#' are ignored. To always have \\`cg log\\` and\n+\t\\`cg diff\\` output colored put the following in ~/.cogito.conf:\n+\n+\t\tlog -c\n+\t\tdiff -c\n+\n COPYRIGHT\n ---------\n Copyright (C) Petr Baudis, 2005.\ndiff --git a/cg b/cg\n--- a/cg\n+++ b/cg\n@@ -3,5 +3,9 @@\n cmd=\"$1\"; shift\n [ x\"$cmd\" = x\"--help\" ] && cmd=\"help\"\n \n+if [ -e \"$HOME/.cogito.conf\" ]; then\n+\tdefaults=\"$(grep \"^$cmd\" \"$HOME/.cogito.conf\" | sed \"s/^$cmd //\")\"\n+fi\n+\n exe=\"cg-$cmd\"\n-exec $exe \"$@\"\n+exec $exe \"$defaults\" \"$@\"\n\n-- \nJonas Fonseca\n"},{"id":"4766","messageId":"20050609083243.GD29665@pasky.ji.cz","threadId":"871","inReplyTo":"20050609010056.GA9084@diku.dk","subject":"Re: [PATCH] Add support reading default options from conf file","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-06-09T08:32:43Z","receivedAt":"2005-06-09T08:32:43Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Thu, Jun 09, 2005 at 03:00:56AM CEST, I got a letter\nwhere Jonas Fonseca <fonseca@diku.dk> told me that...\n> Reply-To: \n> In-Reply-To: <42A754D5.10705@gmail.com>\n> \n> Dan Holmsand <holmsand@gmail.com> wrote Wed, Jun 08, 2005:\n> > - Automatic color if the COGITO_AUTO_COLOR environment variable is set.\n> \n> [ This has been discussed before. Default arguments. The 'new' cg\n>   wrapper makes this very easy. Not as smart as your env variable\n>   handling tho'. ]\n> \n> The default options are read only for Cogito calls going through the new\n> cg wrapper which makes it trivial to 'overwrite' them by just calling\n> cg-COMMAMD.\n> \n> Signed-off-by: Jonas Fonseca <fonseca@diku.dk>\n\nNo, this is the wrong way. The 'cg' wrapper must not really do anything\nspecial on its own. It's not a _replacement_ for direct calling of the\ncg-scripts, it's just an aid for people who don't want to get used to\nit. So please do this in cg-Xlib.\n\nAlso, I'd prefer the config file to be something like ~/.cgrc. I want to\nreserve the .conf file for something more sophisticated. ;-)\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\n<Espy> be careful, some twit might quote you out of context..\n"},{"id":"4840","messageId":"20050611010931.GA13272@diku.dk","threadId":"871","inReplyTo":"20050609083243.GD29665@pasky.ji.cz","subject":"[PATCH] Read default options from config file","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-06-11T01:09:31Z","receivedAt":"2005-06-11T01:09:31Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Petr Baudis <pasky@ucw.cz> wrote Thu, Jun 09, 2005:\n> Dear diary, on Thu, Jun 09, 2005 at 03:00:56AM CEST, I got a letter\n> where Jonas Fonseca <fonseca@diku.dk> told me that...\n> > \n> > Dan Holmsand <holmsand@gmail.com> wrote Wed, Jun 08, 2005:\n> > > - Automatic color if the COGITO_AUTO_COLOR environment variable is set.\n> > \n> > [ This has been discussed before. Default arguments. The 'new' cg\n> >   wrapper makes this very easy. Not as smart as your env variable\n> >   handling tho'. ]\n> > \n> > The default options are read only for Cogito calls going through the new\n> > cg wrapper which makes it trivial to 'overwrite' them by just calling\n> > cg-COMMAMD.\n> \n> No, this is the wrong way. The 'cg' wrapper must not really do anything\n> special on its own. It's not a _replacement_ for direct calling of the\n> cg-scripts, it's just an aid for people who don't want to get used to\n> it. So please do this in cg-Xlib.\n> \n> Also, I'd prefer the config file to be something like ~/.cgrc. I want to\n> reserve the .conf file for something more sophisticated. ;-)\n\nWith the optparse stuff in things got a lot easier. I took the idea to\ncheck for stole from Dan Holmsands patches to only read it when stdout\nis a terminal. So the file is really only for interactive usage.\n\n---\n\nIntroduce ~/.cgrc config file. The file is read on startup if stdout is\na terminal and may contain information about default command line\noptions. Each line consists of a command name and a list of options.\nLines not starting with a 'Cogito' command name are ignored.\n\nTo always have cg-log and cg-diff colorize the output put the followig\nin ~/.cgrc:\n\n\tlog -c\n\tdiff -c\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n---\n\n Documentation/make-cogito-asciidoc |   13 +++++++++++++\n cg-Xlib                            |    7 +++++++\n 2 files changed, 20 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/make-cogito-asciidoc b/Documentation/make-cogito-asciidoc\n--- a/Documentation/make-cogito-asciidoc\n+++ b/Documentation/make-cogito-asciidoc\n@@ -140,6 +140,19 @@ FILE::\n \tIndicates an already existing filename - always relative to the root\n \tof the repository.\n \n+FILES\n+-----\n+~/.cgrc::\n+\tThis file is read on startup if \\`stdout\\` is a terminal and may\n+\tcontain information about default command line options. Each line\n+\tconsists of a command name and a list of options. Lines not\n+\tstarting with a 'Cogito' command name are ignored. To have\n+\t\\`cg-log\\` and \\`cg-diff\\` colorize the output put the following\n+\tin ~/.cgrc:\n+\n+\t\tlog -c\n+\t\tdiff -c\n+\n COPYRIGHT\n ---------\n Copyright (C) Petr Baudis, 2005.\ndiff --git a/cg-Xlib b/cg-Xlib\n--- a/cg-Xlib\n+++ b/cg-Xlib\n@@ -150,6 +150,13 @@ done\n ARGS=(\"$@\")\n ARGPOS=0\n \n+if [ -t 1 -a -e \"$HOME/.cgrc\" ]; then\n+\t_cg_name=${_cg_cmd#cg-}\n+\t_cg_defaults=\"$(sed -n \"/^$_cg_name/s/^$_cg_name //p\" < $HOME/.cgrc)\"\n+\tARGS=($_cg_defaults \"${ARGS[@]}\")\n+fi\n+\n+\n optshift() {\n \tunset ARGS[$ARGPOS]\n \tARGS=(\"${ARGS[@]}\")\n-- \nJonas Fonseca\n"}]}