1

GitHub - andyjda/sticky-shell: Minor mode to keep track of previous prompt in yo...

 1 year ago
source link: https://github.com/andyjda/sticky-shell
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README

Table of Contents

  • In any shell within Emacs, run M-x sticky-shell-mode to enable the mode locally.
  • To enable the mode for all shell buffers, run M-x sticky-shell-global-mode.

The mode should work in any shell that inherits from `eshell-mode’ or `comint-mode’. This includes most language-interpreters I could try (Python, Clojure, etc). If you find a shell for which the mode doesn’t work, please let me know.

Install

The package is available through MELPA. To install from there:

  • Make sure MELPA is in your package archives
    (require 'package)
    (add-to-list 'package-archives
                 '("melpa-stable" . "https://stable.melpa.org/packages/") t)
        
  • then:

interactively

  • M-x package-refresh-contents
  • M-x package-install sticky-shell

with use-package

You can install and configure with use-package:

(use-package sticky-shell
  :ensure t ; install
  ;; add your customization here
  )

Customize

The customizable variable is `sticky-shell-get-prompt’

  • `sticky-shell-get-prompt’ is the function determining which prompt to show: the available options are
    • `sticky-shell-latest-prompt’
    • `sticky-shell-prompt-above-visible’
    • `sticky-shell-prompt-above-cursor’

    (see the functions’ doc strings for a detailed explanation).

    You can also write your own function and assign it to this variable.

Shorten header

Some times, a prompt is too long to fit within a one-line header. For these cases, `sticky-shell-shorten-header-mode’ can be used to shorten the prompt, ensuring that the beginning and end of the prompt are always visible within the header (see fourth screenshot).

This mode can be enabled or disabled with the usual mechanism (calling the `sticky-shell-shorten-header-mode’ function).

If you wish for the header to be shortened by default, add `sticky-shell-shorten-header-set-mode’ to the `sticky-shell-mode-hook’. This function ensures that `sticky-shell-shorten-header-mode’ is enabled/disabled together with `sticky-shell-mode’.

Screenshots

Show prompt above visible line

https://github.com/andyjda/sticky-shell/blob/main/screenshots/make.png

https://github.com/andyjda/sticky-shell/blob/main/screenshots/make_clean.png

A comint shell using `sticky-shell-prompt-above-visible’

Show prompt above cursor

https://github.com/andyjda/sticky-shell/blob/main/screenshots/eshell-prompt-above-cursor.png

An eshell using `sticky-shell-prompt-above-cursor’

Shorten header

https://github.com/andyjda/sticky-shell/blob/shorten-header/screenshots/eshell-shorten-header-mode.png

An eshell using `sticky-shell-shorten-header-mode’ with `sticky-shell-prompt-above-cursor’

Contribute/Issues

Please contact me here if you’d like to add features or if you encounter any issues while using this package.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK