GithubHelp home page GithubHelp logo

shrir / spacemacs-shell-multi-term-stickiness Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 69 KB

Spacemacs shell layer configuration for Emacs multi-term sticky mode

Home Page: https://github.com/shrir/emacs-multi-term-stickiness

spacemacs-layer terminal shell

spacemacs-shell-multi-term-stickiness's Introduction

Shell layer

img/shell.png

Table of Contents

Description

This layer configures the various shells available in Emacs.

Install

To use this configuration layer, add it to your ~/.spacemacs. You will need to add shell to the existing dotspacemacs-configuration-layers list in this file.

Configuration

Default shell

Emacs supports three types of shell:

  • the Emacs shell
  • the inferior shell
  • the terminal emulator
  • the ANSI terminal emulator

You can find a quick introductions to them here.

To define the default shell you can set the layer variable shell-default-shell to the following variables:

  • eshell
  • shell
  • term
  • ansi-term
  • multi-term
(setq-default dotspacemacs-configuration-layers
  '((shell :variables shell-default-shell 'eshell)))

The default shell is quickly accessible via a the default shortcut key SPC '​.

Default shell position and height

It is possible to choose where the shell should pop up by setting the variable shell-default-position to either top, bottom, left, right, or full. Default value is bottom. It is also possible to set the default height in percents with the variable shell-default-height. Default value is 30.

(setq-default dotspacemacs-configuration-layers
  '((shell :variables
           shell-default-position 'bottom
           shell-default-height 30)))

Set shell for term and ansi-term

The default shell can be set by setting the variable shell-default-term-shell. Default value is /bin/bash.

(setq-default dotspacemacs-configuration-layers
  '((shell :variables shell-default-term-shell "/bin/bash")))

Width of the shell popup buffers

By default the popup buffer spans the full width of the current frame, if you prefer to spans only the width of the current window then set the layer variable shell-default-full-span to nil.

(setq-default dotspacemacs-configuration-layers
  '((shell :variables shell-default-full-span nil)))

Enable em-smart in Eshell

From the em-smart documentation:

The best way to get a sense of what this code is trying to do is by using it. Basically, the philosophy represents a blend between the ease of use of modern day shells, and the review-before-you-proceed mentality of Plan 9’s 9term.

In a nutshell, when em-smart is enabled point won’t jump at the end of the buffer when a command is executed, it will stay at the same command prompt used to execute the command. This allows to quickly edit the last command in the case of a mistake. If there is no mistake and you directly type a new command then the prompt will jump to the next prompt at the end of the buffer.

To enable em-smart put the following layer variable to non-nil:

(setq-default dotspacemacs-configuration-layers
  '((shell :variables shell-enable-smart-eshell t)))

Protect your Eshell prompt

Comint mode (Shell mode) has good support for Evil mode as it inhibits movement commands over the prompt. This has the added benefit that Evil mode functions work sensibly. E.g. you can press cc in normal state i.e. evil-change-whole-line to kill the current input and start typing a new command. In Eshell you also kill the prompt, which is often unintended.

By default this layer also protects the eshell prompt. If you want to disable this protection you can set the variable shell-protect-eshell-prompt to nil.

(setq-default dotspacemacs-configuration-layers
  '((shell :variables shell-protect-eshell-prompt nil)))

Fish shell and ansi-term

Making fish shell to work with ansi-term may be a challenge, here are some pointers to save you time to setup your environment correctly.

First be sure ~/.terminfo is setup correctly by running:

tic -o ~/.terminfo $TERMINFO/e/eterm-color.ti

You can locate the eterm-colors.ti file with:

locate eterm-color.ti

Then setup your fish configuration file (usually at ~/.config/fish/config.fish)

# emacs ansi-term support
if test -n "$EMACS"
  set -x TERM eterm-color
end

# this function may be required
function fish_title
  true
end

Finally you may need to toggle truncated lines for some prompts to work correctly, in the function dotspacemacs/user-config of your dotfile add:

(add-hook 'term-mode-hook 'toggle-truncate-lines)

Eshell

Some advanced configuration is setup for eshell in this layer:

  • some elisp functions aliases for quick access
    • s for magit-status in the current directory (when the git layer is installed)
    • d for dired
    • e to find a file via a new buffer
    • z for quickly jumping to a previously visited directory
  • optional configuration for em-smart (see Install section for more info)
  • support for visual commands via em-term
  • working directory sensitive prompt via eshell-prompt-extras
  • advanced help support via esh-help (enable el-doc support in eshell)
  • add support for auto-completion via company (when the auto-completion layer is installed)
  • pressing i in normal state will automatically jump to the prompt

Key bindings

Key BindingDescription
SPC '​Open, close or go to the default shell
SPC p '​Open a shell in the project’s root
SPC a s eOpen, close or go to an eshell
SPC a s iOpen, close or go to a shell
SPC a s mOpen, close or go to a multi-term
SPC a s tOpen, close or go to a ansi-term
SPC a s TOpen, close or go to a term
SPC m Hbrowse history with helm (works in eshell and shell)
C-jnext item in history
C-kprevious item in history

Note: You can open multiple shells using a numerical prefix argument, for instance pressing 2 SPC '​ will a second default shell, the number of shell is indicated on the mode-line.

Note: Use the universal prefix argument SPC u SPC '​ to open the shell in the current buffer instead of a popup.

Multi-term

Key BindingDescription
SPC m ccreate a new multi-term
SPC m ngo to next multi-term
SPC m pgo to previous multi-term
SPC m stoggle stickiness
SPC p $ trun multi-term shell in root

Note: To use multi term sticky mode, install Emacs multi-term stickiness.

Eshell

Key BindingDescription
SPC m H or M-lshell commands history using a helm buffer

spacemacs-shell-multi-term-stickiness's People

Contributors

bixuanzju avatar darkfeline avatar dubnde avatar jfchevrette avatar joelmccracken avatar nwolfe avatar pschorf avatar shrir avatar stebalien avatar streakycobra avatar syl20bnr avatar thebb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.