From: Daniel Carl Date: Sun, 19 Jan 2014 20:55:31 +0000 (+0100) Subject: Allow to run ex command given as option string (#58). X-Git-Url: https://git.owens.tech/about.html/about.html/git?a=commitdiff_plain;h=804064884f7fef50f99b8fa5fcfa028462520f5e;p=vimb.git Allow to run ex command given as option string (#58). --- diff --git a/doc/vimb.1 b/doc/vimb.1 index 79d95d9..db0d0fb 100644 --- a/doc/vimb.1 +++ b/doc/vimb.1 @@ -15,7 +15,13 @@ browsing-experience. .SH OPTIONS Mandatory arguments to long options are mandatory for short options too. .TP -.BI "\-c, \--config " "CONFIG-FILE" +.BI "\-C, \-\-cmd " "CMD" +Run \fICMD\fP as ex command line right before the first page is loaded. +Several ex commands can be used separated by "|". +.br +Example: `vimb --cmd "set cookie-accept=origin|set header=Referer,DNT=1"` +.TP +.BI "\-c, \-\-config " "CONFIG-FILE" Use custom configuration given as \fICONFIG-FILE\fP. .TP .BI "\-e, \-\-embed " "WINID" diff --git a/src/main.c b/src/main.c index 57d7447..5a89260 100644 --- a/src/main.c +++ b/src/main.c @@ -943,12 +943,14 @@ int main(int argc, char *argv[]) static char *winid = NULL; static gboolean ver = false; static GError *err; + static char *cmd = NULL; vb.custom_config = NULL; static GOptionEntry opts[] = { - {"version", 'v', 0, G_OPTION_ARG_NONE, &ver, "Print version", NULL}, + {"cmd", 'C', 0, G_OPTION_ARG_STRING, &cmd, "Ex command run before first page is loaded", NULL}, {"config", 'c', 0, G_OPTION_ARG_STRING, &vb.custom_config, "Custom cufiguration file", NULL}, {"embed", 'e', 0, G_OPTION_ARG_STRING, &winid, "Reparents to window specified by xid", NULL}, + {"version", 'v', 0, G_OPTION_ARG_NONE, &ver, "Print version", NULL}, {NULL} }; /* Initialize GTK+ */ @@ -973,6 +975,11 @@ int main(int argc, char *argv[]) init_core(); + /* process the --cmd if this was given */ + if (cmd) { + ex_run_string(cmd); + } + /* command line argument: URL */ vb_load_uri(&(Arg){VB_TARGET_CURRENT, argc > 1 ? argv[argc - 1] : NULL});