Add a configurable prefix for commands sent to the shell in the VTE

This adds an hidden VTE preference, send_cmd_prefix, that allows to
define a prefix for the commands Geany sends to the shell in the VTE
like "cd" when following current path.

This can be used for example to prevent some shells (Bash, ZSH, maybe
others) from putting these commands in the history by setting this to
a space.
This commit is contained in:
Colomban Wendling 2011-11-17 03:36:11 +01:00
parent 5b41e177de
commit 59eb0557b6
5 changed files with 6746 additions and 6719 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2512,6 +2512,15 @@ send_selection_unsafe By default, Geany strips any trailing f
If, for whatever reasons, you really want
it to be executed directly, set this option
to true.
send_cmd_prefix String with which prefix the commands sent Empty immediately
to the shell. This may be used to tell
some shells (BASH with ``HISTCONTROL`` set
to ``ignorespace``, ZSH with
``HIST_IGNORE_SPACE`` enabled, etc.) from
putting these commands in their history by
setting this to a space. Note that leading
spaces must be escaped using `\s` in the
configuration file.
**File related**
use_atomic_file_saving Defines the mode how Geany saves files to false immediately
disk. If disabled, Geany directly writes

View File

@ -496,6 +496,8 @@ static void save_dialog_prefs(GKeyFile *config)
if (!g_key_file_has_key(config, "VTE", "send_selection_unsafe", NULL)) /* hidden */
g_key_file_set_boolean(config, "VTE", "send_selection_unsafe",
vc->send_selection_unsafe);
if (!g_key_file_has_key(config, "VTE", "send_cmd_prefix", NULL)) /* hidden */
g_key_file_set_string(config, "VTE", "send_cmd_prefix", vc->send_cmd_prefix);
g_key_file_set_string(config, "VTE", "font", vc->font);
g_key_file_set_boolean(config, "VTE", "scroll_on_key", vc->scroll_on_key);
g_key_file_set_boolean(config, "VTE", "scroll_on_out", vc->scroll_on_out);
@ -826,6 +828,7 @@ static void load_dialog_prefs(GKeyFile *config)
vc->enable_bash_keys = utils_get_setting_boolean(config, "VTE", "enable_bash_keys", TRUE);
vc->ignore_menu_bar_accel = utils_get_setting_boolean(config, "VTE", "ignore_menu_bar_accel", FALSE);
vc->follow_path = utils_get_setting_boolean(config, "VTE", "follow_path", FALSE);
vc->send_cmd_prefix = utils_get_setting_string(config, "VTE", "send_cmd_prefix", "");
vc->run_in_vte = utils_get_setting_boolean(config, "VTE", "run_in_vte", FALSE);
vc->skip_run_script = utils_get_setting_boolean(config, "VTE", "skip_run_script", FALSE);
vc->cursor_blinks = utils_get_setting_boolean(config, "VTE", "cursor_blinks", FALSE);

View File

@ -298,6 +298,7 @@ void vte_close(void)
g_free(vc->font);
g_free(vc->colour_back);
g_free(vc->colour_fore);
g_free(vc->send_cmd_prefix);
g_free(vc);
g_free(gtk_menu_key_accel);
/* Don't unload the module explicitly because it causes a segfault on FreeBSD. The segfault
@ -660,7 +661,7 @@ void vte_cwd(const gchar *filename, gboolean force)
{
/* use g_shell_quote to avoid problems with spaces, '!' or something else in path */
gchar *quoted_path = g_shell_quote(path);
gchar *cmd = g_strconcat("cd ", quoted_path, "\n", NULL);
gchar *cmd = g_strconcat(vc->send_cmd_prefix, "cd ", quoted_path, "\n", NULL);
if (! vte_send_cmd(cmd))
{
ui_set_statusbar(FALSE,

View File

@ -55,6 +55,7 @@ typedef struct
gchar *emulation;
gchar *shell;
gchar *font;
gchar *send_cmd_prefix;
GdkColor *colour_fore;
GdkColor *colour_back;
} VteConfig;