Difference between revisions of "Shell"

From WikEmacs
Jump to navigation Jump to search
(Replaced content with " Category:Shell")
(shell mode tips)
Line 1: Line 1:
 +
'''Shell-mode''' gives access to a shell in a normal emacs buffer, meaning you can move around and edit it as usual. A drawback is that you can not launch programs like htop or other ncurses ones.
 +
 +
= Usage =
 +
 +
{{Command|shell}}
 +
 +
Look at the menu: you have several key to interact with the shell. Some of them are:
 +
 +
* {{Keys|M-p}} previous input of command line
 +
* {{Keys|C-c r}} go to beginnig of output (useful when you have a large output and want to read through the beginning)
 +
* {{Keys|C-c-p}} go to beginnig of previous output group
 +
 +
 +
To launch a shell in the current buffer, have a look to '''shell-here''': https://github.com/ieure/shell-here (available through ELPA).
 +
 +
= Customisation =
 +
 +
== More colors ==
 +
 +
If you have bad colors in the output, try using '''ansi-mode''':
 +
 +
    (require 'ansi-color)
 +
    (defun colorize-compilation-buffer ()
 +
    (toggle-read-only)
 +
    (ansi-color-apply-on-region (point-min) (point-max))
 +
      (toggle-read-only))
 +
      (add-hook 'compilation-filter-hook 'colorize-compilation-buffer)
 +
 +
You can highlight some text based on regexp (useful to see "OK" or warnings):
 +
 +
      (add-hook 'shell-mode-hook (lambda () (highlight-regexp "\\[OK\\]" "hi-green-b")))
 +
 +
 +
== Make URLs clikable ==
 +
 +
   
 +
    (add-hook 'shell-mode-hook (lambda () (goto-address-mode )))
 +
 +
 +
= See also =
 +
 +
'''shell-pop''' to pop up and pop out a shell buffer window easily (installable via ELPA).
  
  
 
[[Category:Shell]]
 
[[Category:Shell]]

Revision as of 17:38, 19 December 2013

Shell-mode gives access to a shell in a normal emacs buffer, meaning you can move around and edit it as usual. A drawback is that you can not launch programs like htop or other ncurses ones.

Usage

M-x shell

Look at the menu: you have several key to interact with the shell. Some of them are:

  • [M-p] previous input of command line
  • [C-c r] go to beginnig of output (useful when you have a large output and want to read through the beginning)
  • [C-c-p] go to beginnig of previous output group


To launch a shell in the current buffer, have a look to shell-here: https://github.com/ieure/shell-here (available through ELPA).

Customisation

More colors

If you have bad colors in the output, try using ansi-mode:

    (require 'ansi-color)
    (defun colorize-compilation-buffer ()
    (toggle-read-only)
    (ansi-color-apply-on-region (point-min) (point-max))
      (toggle-read-only))
      (add-hook 'compilation-filter-hook 'colorize-compilation-buffer)

You can highlight some text based on regexp (useful to see "OK" or warnings):

      (add-hook 'shell-mode-hook (lambda () (highlight-regexp "\\[OK\\]" "hi-green-b")))


Make URLs clikable

   (add-hook 'shell-mode-hook (lambda () (goto-address-mode ))) 


See also

shell-pop to pop up and pop out a shell buffer window easily (installable via ELPA).