add support for opening terminal in set directory

This commit is contained in:
Daniel Micay 2012-10-21 18:32:49 -04:00
parent b76df7f5b2
commit 5190acf978
2 changed files with 46 additions and 15 deletions

View File

@ -6,8 +6,8 @@ unset) and then falls back to ``$XDG_CONFIG_DIRS``.
DEPENDENCIES DEPENDENCIES
============ ============
A vte version >= 0.30. A patch is required to expose the functions needed for A vte version >= ``0.34``. A patch is required to expose the functions needed
keyboard selection. for keyboard selection.
KEYBINDINGS KEYBINDINGS
=========== ===========
@ -15,19 +15,35 @@ KEYBINDINGS
INSERT MODE INSERT MODE
----------- -----------
+-----------------------+--------------------------------------+ +-----------------------+---------------------------------------------+
| ``ctrl-shift-escape`` | reload configuration file | | ``ctrl-shift-escape`` | reload configuration file |
+-----------------------+--------------------------------------+ +-----------------------+---------------------------------------------+
| ``ctrl-shift-c`` | copy to CLIPBOARD | | ``ctrl-shift-c`` | copy to CLIPBOARD |
+-----------------------+--------------------------------------+ +-----------------------+---------------------------------------------+
| ``ctrl-shift-v`` | paste from CLIPBOARD | | ``ctrl-shift-v`` | paste from CLIPBOARD |
+-----------------------+--------------------------------------+ +-----------------------+---------------------------------------------+
| ``ctrl-shift-u`` | unicode input (standard GTK binding) | | ``ctrl-shift-u`` | unicode input (standard GTK binding) |
+-----------------------+--------------------------------------+ +-----------------------+---------------------------------------------+
| ``ctrl-tab`` | start scrollback completion | | ``ctrl-tab`` | start scrollback completion |
+-----------------------+--------------------------------------+ +-----------------------+---------------------------------------------+
| ``ctrl-shift-space`` | start command mode | | ``ctrl-shift-space`` | start command mode |
+-----------------------+--------------------------------------+ +-----------------------+---------------------------------------------+
| ``ctrl-shift-t`` | open terminal in the current directory [1]_ |
+-----------------------+---------------------------------------------+
.. [1] The directory can be set by a process running in the terminal. For
example, with zsh:
.. code:: sh
if [[ $TERM == xterm-termite ]]; then
. /etc/profile.d/vte.sh
chpwd() {
__vte_ps1
}
fi
COMMAND MODE COMMAND MODE
------------ ------------

View File

@ -102,6 +102,18 @@ void launch_browser(char *browser, char *url) {
g_spawn_async(NULL, browser_cmd, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL); g_spawn_async(NULL, browser_cmd, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
} }
static void launch_in_directory(VteTerminal *vte) {
const char *uri = vte_terminal_get_current_directory_uri(vte);
if (!uri) {
g_printerr("no directory uri set");
return;
}
auto dir = make_unique(g_filename_from_uri(uri, nullptr, nullptr), g_free);
char term[] = "termite"; // maybe this should be argv[0]
char *cmd[] = {term, nullptr};
g_spawn_async(dir.get(), cmd, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
}
static void find_urls(VteTerminal *vte, search_panel_info *panel_info) { static void find_urls(VteTerminal *vte, search_panel_info *panel_info) {
GRegex *regex = g_regex_new(url_regex, G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY, NULL); GRegex *regex = g_regex_new(url_regex, G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY, NULL);
GArray *attributes = g_array_new(FALSE, FALSE, sizeof (vte_char_attributes)); GArray *attributes = g_array_new(FALSE, FALSE, sizeof (vte_char_attributes));
@ -583,6 +595,9 @@ gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, keybind_info *info)
} }
if (modifiers == (GDK_CONTROL_MASK|GDK_SHIFT_MASK)) { if (modifiers == (GDK_CONTROL_MASK|GDK_SHIFT_MASK)) {
switch (gdk_keyval_to_lower(event->keyval)) { switch (gdk_keyval_to_lower(event->keyval)) {
case GDK_KEY_t:
launch_in_directory(vte);
return TRUE;
case GDK_KEY_space: case GDK_KEY_space:
enter_command_mode(vte, &info->select); enter_command_mode(vte, &info->select);
return TRUE; return TRUE;