Index: src/gnome-terminal.schemas.in
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/gnome-terminal.schemas.in,v
retrieving revision 1.43
diff -u -p -r1.43 gnome-terminal.schemas.in
--- src/gnome-terminal.schemas.in	5 Jan 2006 15:39:17 -0000	1.43
+++ src/gnome-terminal.schemas.in	9 Jan 2006 13:56:32 -0000
@@ -682,6 +682,23 @@
       </locale>
     </schema>
 
+     <schema>
+      <key>/schemas/apps/gnome-terminal/keybindings/save_tab</key>
+      <applyto>/apps/gnome-terminal/keybindings/save_tab</applyto>
+      <owner>gnome-terminal</owner>
+      <type>string</type>
+      <default>disabled</default>
+      <locale name="C">
+         <short>Keyboard shortcut to save the current tab to file</short>
+         <long>
+          Keyboard shortcut key to save the current tab to a file. Expressed as a string
+          in the same format used for GTK+ resource files.
+          If you set the option to the special string "disabled", then there 
+          will be no keyboard shortcut for this action.
+         </long>
+      </locale>
+    </schema>
+
     <schema>
       <key>/schemas/apps/gnome-terminal/keybindings/close_tab</key>
       <applyto>/apps/gnome-terminal/keybindings/close_tab</applyto>
Index: src/terminal-accels.c
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/terminal-accels.c,v
retrieving revision 1.31
diff -u -p -r1.31 terminal-accels.c
--- src/terminal-accels.c	5 Jan 2006 15:39:17 -0000	1.31
+++ src/terminal-accels.c	9 Jan 2006 13:56:32 -0000
@@ -33,6 +33,7 @@
 #define KEY_NEW_TAB CONF_KEYS_PREFIX"/new_tab"
 #define KEY_NEW_WINDOW CONF_KEYS_PREFIX"/new_window"
 #define KEY_NEW_PROFILE CONF_KEYS_PREFIX"/new_profile"
+#define KEY_SAVE_TAB CONF_KEYS_PREFIX"/save_tab"
 #define KEY_CLOSE_TAB CONF_KEYS_PREFIX"/close_tab"
 #define KEY_CLOSE_WINDOW CONF_KEYS_PREFIX"/close_window"
 #define KEY_COPY CONF_KEYS_PREFIX"/copy"
@@ -81,6 +82,8 @@ static KeyEntry file_entries[] =
     KEY_NEW_WINDOW, ACCEL_PATH_NEW_WINDOW, 0, 0, NULL, FALSE },
   { N_("New Profile"),
     KEY_NEW_PROFILE, ACCEL_PATH_NEW_PROFILE, 0, 0, NULL, FALSE },
+  { N_("Save Tab"),
+    KEY_SAVE_TAB, ACCEL_PATH_SAVE_TAB, 0, 0, NULL, FALSE },
   { N_("Close Tab"),
     KEY_CLOSE_TAB, ACCEL_PATH_CLOSE_TAB, 0, 0, NULL, FALSE },
   { N_("Close Window"),
Index: src/terminal-accels.h
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/terminal-accels.h,v
retrieving revision 1.10
diff -u -p -r1.10 terminal-accels.h
--- src/terminal-accels.h	20 Nov 2005 15:06:33 -0000	1.10
+++ src/terminal-accels.h	9 Jan 2006 13:56:32 -0000
@@ -32,6 +32,7 @@ GtkAccelGroup* terminal_accels_get_group
 #define ACCEL_PATH_NEW_TAB ACCEL_PATH_ROOT"/new_tab"
 #define ACCEL_PATH_NEW_WINDOW ACCEL_PATH_ROOT"/new_window"
 #define ACCEL_PATH_NEW_PROFILE ACCEL_PATH_ROOT"/new_profile"
+#define ACCEL_PATH_SAVE_TAB ACCEL_PATH_ROOT"/save_tab"
 #define ACCEL_PATH_CLOSE_TAB ACCEL_PATH_ROOT"/close_tab"
 #define ACCEL_PATH_CLOSE_WINDOW ACCEL_PATH_ROOT"/close_window"
 #define ACCEL_PATH_COPY ACCEL_PATH_ROOT"/copy"
Index: src/terminal-screen.c
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/terminal-screen.c,v
retrieving revision 1.111
diff -u -p -r1.111 terminal-screen.c
--- src/terminal-screen.c	9 Jan 2006 02:11:23 -0000	1.111
+++ src/terminal-screen.c	9 Jan 2006 13:56:34 -0000
@@ -1203,6 +1203,13 @@ terminal_screen_launch_child (TerminalSc
   g_strfreev (env);
 }
 
+const char* 
+terminal_get_scrollback_text (TerminalScreen *screen)
+{
+  g_return_val_if_fail (screen->priv->window, NULL);
+  return terminal_widget_get_scrollback_text (screen->priv->term);
+}
+
 void
 terminal_screen_close (TerminalScreen *screen)
 {
Index: src/terminal-screen.h
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/terminal-screen.h,v
retrieving revision 1.12
diff -u -p -r1.12 terminal-screen.h
--- src/terminal-screen.h	1 Jan 2006 21:07:57 -0000	1.12
+++ src/terminal-screen.h	9 Jan 2006 13:56:34 -0000
@@ -90,6 +90,8 @@ const char* terminal_screen_get_title   
 const char* terminal_screen_get_icon_title     (TerminalScreen *screen);
 gboolean    terminal_screen_get_icon_title_set (TerminalScreen *screen);
 
+const char* terminal_get_scrollback_text (TerminalScreen *screen);
+
 void terminal_screen_close (TerminalScreen *screen);
 
 gboolean terminal_screen_get_text_selected (TerminalScreen *screen);
Index: src/terminal-widget-vte.c
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/terminal-widget-vte.c,v
retrieving revision 1.34
diff -u -p -r1.34 terminal-widget-vte.c
--- src/terminal-widget-vte.c	28 Jun 2004 07:44:02 -0000	1.34
+++ src/terminal-widget-vte.c	9 Jan 2006 13:56:34 -0000
@@ -539,6 +539,33 @@ terminal_widget_get_has_selection (GtkWi
   return vte_terminal_get_has_selection(VTE_TERMINAL(widget));
 }
 
+static gboolean
+always_selected(VteTerminal *terminal, glong row, glong column, gpointer data)
+{
+  return TRUE;
+}
+
+const char*
+terminal_widget_get_scrollback_text (GtkWidget *widget)
+{
+  GArray *array;
+  VteTerminal *terminal;
+  glong rows, cols;
+
+  terminal = VTE_TERMINAL (widget);
+  g_return_val_if_fail (VTE_IS_TERMINAL(terminal), NULL);
+
+  array = g_array_new(FALSE, TRUE, sizeof(struct _VteCharAttributes));
+  cols = vte_terminal_get_column_count (terminal);
+  rows = vte_terminal_get_current_scrollback_lines(terminal);
+
+  return vte_terminal_get_text_range (terminal,
+      0, 0,
+      rows, cols,
+      always_selected,
+      NULL,
+      array);
+}
 
 GtkAdjustment*
 terminal_widget_get_scroll_adjustment (GtkWidget *widget)
Index: src/terminal-widget.h
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/terminal-widget.h,v
retrieving revision 1.10
diff -u -p -r1.10 terminal-widget.h
--- src/terminal-widget.h	28 Jun 2004 07:44:02 -0000	1.10
+++ src/terminal-widget.h	9 Jan 2006 13:56:34 -0000
@@ -142,6 +142,8 @@ const char* terminal_widget_get_title   
 const char* terminal_widget_get_icon_title    (GtkWidget *widget);
 gboolean    terminal_widget_get_has_selection (GtkWidget *widget);
 
+const char* terminal_widget_get_scrollback_text (GtkWidget *widget);
+
 GtkAdjustment* terminal_widget_get_scroll_adjustment (GtkWidget *widget);
 
 gboolean terminal_widget_fork_command      (GtkWidget   *widget,
Index: src/terminal-window.c
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/terminal-window.c,v
retrieving revision 1.120
diff -u -p -r1.120 terminal-window.c
--- src/terminal-window.c	9 Jan 2006 02:16:31 -0000	1.120
+++ src/terminal-window.c	9 Jan 2006 13:56:35 -0000
@@ -48,6 +48,7 @@ struct _TerminalWindowPrivate
   GtkWidget *help_menuitem;
   GtkWidget *new_window_menuitem;
   GtkWidget *new_tab_menuitem;
+  GtkWidget *save_tab_menuitem;
   GtkWidget *close_tab_menuitem;
   GtkWidget *copy_menuitem;
   GtkWidget *paste_menuitem;
@@ -161,6 +162,8 @@ static gboolean key_press_callback	  (Gt
 					   TerminalWindow *window);
 static void close_window_callback         (GtkWidget      *menuitem,
                                            TerminalWindow *window);
+static void save_tab_callback             (GtkWidget      *menuitem,
+                                           TerminalWindow *window);
 static void close_tab_callback            (GtkWidget      *menuitem,
                                            TerminalWindow *window);
 static void copy_callback                 (GtkWidget      *menuitem,
@@ -869,6 +872,11 @@ terminal_window_init (TerminalWindow *wi
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
 
   window->priv->close_tab_menuitem = 
+    append_menuitem (menu, _("_Save Tab"), ACCEL_PATH_SAVE_TAB,
+                     G_CALLBACK (save_tab_callback),
+                     window);
+  
+  window->priv->close_tab_menuitem = 
     append_menuitem (menu, _("C_lose Tab"), ACCEL_PATH_CLOSE_TAB,
                      G_CALLBACK (close_tab_callback),
                      window);
@@ -2299,6 +2307,43 @@ close_window_callback (GtkWidget      *m
 {
   if (confirm_close_window (window))
     gtk_widget_destroy (GTK_WIDGET (window));
+}
+
+static void
+save_tab_callback (GtkWidget      *menuitem,
+                    TerminalWindow *window)
+{
+  gchar *filename = NULL;
+  FILE  *fd;
+  GtkWidget *dialog = NULL;
+
+  // ask for file location
+  dialog = gtk_file_chooser_dialog_new ( _("Save as..."),
+      NULL,
+      GTK_FILE_CHOOSER_ACTION_SAVE,
+      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+      GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+      NULL);
+
+  if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
+    filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+
+  gtk_widget_destroy (dialog);
+
+  g_return_if_fail (filename!=NULL);
+
+  // save all current scrollback lines
+  fd = fopen (filename,"w");
+
+  if (fd != NULL && window->priv->active_term)
+  {
+    fputs (terminal_get_scrollback_text (window->priv->active_term), fd);
+    fclose(fd);
+  } else {
+    g_warning ("Could not write file: %s\n", filename);
+  }
+
+  g_free(filename);
 }
 
 static void
