diff --git a/src/bin/config.c b/src/bin/config.c index 372ed24b..4486f589 100644 --- a/src/bin/config.c +++ b/src/bin/config.c @@ -7,7 +7,7 @@ #include "col.h" #include "utils.h" -#define CONF_VER 6 +#define CONF_VER 7 #define LIM(v, min, max) {if (v >= max) v = max; else if (v <= min) v = min;} @@ -165,6 +165,8 @@ config_init(void) (edd_base, Config, "mv_always_show", mv_always_show, EET_T_UCHAR); EET_DATA_DESCRIPTOR_ADD_BASIC (edd_base, Config, "ty_escapes", ty_escapes, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC + (edd_base, Config, "changedir_to_current", changedir_to_current, EET_T_UCHAR); } void @@ -265,6 +267,7 @@ config_sync(const Config *config_src, Config *config) config->notabs = config_src->notabs; config->mv_always_show = config_src->mv_always_show; config->ty_escapes = config_src->ty_escapes; + config->changedir_to_current = config_src->changedir_to_current; } static void @@ -480,6 +483,7 @@ config_new(void) config->notabs = EINA_FALSE; config->mv_always_show = EINA_FALSE; config->ty_escapes = EINA_TRUE; + config->changedir_to_current = EINA_TRUE; for (j = 0; j < 4; j++) { for (i = 0; i < 12; i++) @@ -549,7 +553,10 @@ config_load(const char *key) case 5: config->ty_escapes = EINA_TRUE; /*pass through*/ - case CONF_VER: /* 6 */ + case 6: + config->changedir_to_current = EINA_TRUE; + /*pass through*/ + case CONF_VER: /* 7 */ config->version = CONF_VER; break; default: @@ -645,6 +652,7 @@ config_fork(Config *config) CPY(notabs); CPY(mv_always_show); CPY(ty_escapes); + CPY(changedir_to_current); EINA_LIST_FOREACH(config->keys, l, key) { diff --git a/src/bin/config.h b/src/bin/config.h index d6a8a939..fb9e148a 100644 --- a/src/bin/config.h +++ b/src/bin/config.h @@ -76,6 +76,7 @@ struct _Config Eina_Bool notabs; Eina_Bool mv_always_show; Eina_Bool ty_escapes; + Eina_Bool changedir_to_current; Config_Color colors[(4 * 12)]; Eina_List *keys; diff --git a/src/bin/options_behavior.c b/src/bin/options_behavior.c index d889a467..bcff7015 100644 --- a/src/bin/options_behavior.c +++ b/src/bin/options_behavior.c @@ -43,6 +43,7 @@ CB(gravatar, 0); CB(notabs, 1); CB(mv_always_show, 0); CB(ty_escapes, 0); +CB(changedir_to_current, 0); #undef CB @@ -193,6 +194,7 @@ options_behavior(Evas_Object *opbox, Evas_Object *term) CX(_("Show tabs"), notabs, 1); CX(_("Always show miniview"), mv_always_show, 0); CX(_("Enable special Terminology escape codes"), ty_escapes, 0); + CX(_("Open new terminals in current working directory"), changedir_to_current, 0); #undef CX diff --git a/src/bin/win.c b/src/bin/win.c index 23873d8f..640d136b 100644 --- a/src/bin/win.c +++ b/src/bin/win.c @@ -952,16 +952,22 @@ _win_split(Term_Container *tc, Term_Container *child, { Term *tm_new, *tm; Term_Container *tc_split, *tc_solo_new; - char buf[PATH_MAX], *wdir = NULL; + char *wdir = NULL; Evas_Object *base; Evas_Object *o; - if (from) - tm = from; - else - tm = tc->focused_term_get(tc); - if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf))) - wdir = buf; + // copy the current path to wdir if we should change the directory, + // passing wdir NULL otherwise: + if (wn->config->changedir_to_current) + { + if (from) + tm = from; + else + tm = tc->focused_term_get(tc); + char buf[PATH_MAX]; + if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf))) + wdir = buf; + } tm_new = term_new(wn, wn->config, cmd, wn->config->login_shell, wdir, 80, 24, EINA_FALSE); @@ -1438,16 +1444,22 @@ _split_split(Term_Container *tc, Term_Container *child, if (_term_container_is_splittable(tc, is_horizontal)) { Term *tm_new, *tm; - char buf[PATH_MAX], *wdir = NULL; + char *wdir = NULL; Term_Container *tc_split, *tc_solo_new; Evas_Object *obj_split; - if (from) - tm = from; - else - tm = child->focused_term_get(child); - if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf))) - wdir = buf; + // copy the current path to wdir if we should change the directory, + // passing wdir NULL otherwise: + if (wn->config->changedir_to_current) + { + if (from) + tm = from; + else + tm = child->focused_term_get(child); + char buf[PATH_MAX]; + if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf))) + wdir = buf; + } tm_new = term_new(wn, wn->config, cmd, wn->config->login_shell, wdir, 80, 24, EINA_FALSE); @@ -2326,11 +2338,18 @@ _tab_new_cb(void *data, *tc_new, *tc_parent, *tc_old; Term *tm, *tm_new; Win *wn = tc->wn; - char buf[PATH_MAX], *wdir = NULL; + char *wdir = NULL; + + // copy the current path to wdir if we should change the directory, + // passing wdir NULL otherwise: + if (wn->config->changedir_to_current) + { + char buf[PATH_MAX]; + tm = tc->focused_term_get(tc); + if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf))) + wdir = buf; + } - tm = tc->focused_term_get(tc); - if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf))) - wdir = buf; tm_new = term_new(wn, wn->config, NULL, wn->config->login_shell, wdir, 80, 24, EINA_FALSE);