# Key sequence to emulate terminal command prompt

**URL:** <https://discuss.kakoune.com/t/key-sequence-to-emulate-terminal-command-prompt/2963>\
**Category:** Recipes & Guides\
**Created:** [August 11, 2026, 8:29pm UTC](https://discuss.kakoune.com/t/key-sequence-to-emulate-terminal-command-prompt/2963 "2026-08-11T20:29:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregk](https://discuss.kakoune.com/letter_avatar_proxy/v4/letter/g/958977/32.png) [@gregk](https://discuss.kakoune.com/u/gregk)\
**Post date:** [August 11, 2026, 8:29pm UTC](https://discuss.kakoune.com/t/key-sequence-to-emulate-terminal-command-prompt/2963/1 "2026-08-11T20:29:48Z")

</div>

`map global user s %{x<a-!>. /dev/stdin 2>&1<ret>} -docstring 'execute line(s) as shell command(s) delimited by ;'`

- supports (sequential) execution of multiple command lines via kakoune multi selection
- supports multiple shell commands delimited by ; on each line
- remaps stderr to the kakoune buffer
- appears to preclude use of $kak variables  
eg echo $kak\_session does not return the current session id  
presumably because it is not in the . /dev/stdin and kakoune apparently does not scan the input to the source statement  
This is not a major issue because when I’m using a terminal I don’t expect to use $kak\_ variables  
`:exec %{x<a-!>{ pstree -s $$;echo $kak_session; not-found; } 2>&1}<ret>` does handle $kak\_session

Background

I use the kitty terminal emulator. kitty is good at splitting the OS screen but weaker at stacking applications within the same kitty window. (although kitty has a lot of function and is constantly adding function so I may have missed some kitty stacking options) I have tended to run multiple kitty tabs each split into bash and kakoune windows. Some bash windows run other TUI apps besides kakoune. kakoune is good at stacking buffers. I’ve gradually realized that a kakoune buffer can replace most (bash) shells that aren’t already running another TUI application at least when it comes to running my own user scripts.

Benefits

- considerably reduce the number of kitty tabs needed and switching between kitty tabs
- every line of shell output can be interactively reused  
e.g. can list pdfs into a kakoune buffer, then add evince commands in front of each for subsequent execution (or rewrite the list command to emit evince before each filename)
- can comfortably pursue multiple shell projects in one kakoune buffer  
convenient to delete shell output instead of having it scroll to oblivion
- melding of editing and command prompt  
to do a calculation in the middle of editing a text file just insert a new line,  
type the calc command, execute it, copy/paste the answer then delete when done.  
this is handy on smaller physical screens (e.g. laptop) where splitting is not desirable  
kakoune `:exec` can do this but I’m used to doing it from the command line…
- mostly eliminates the need for kitty windows with bash shell prompts,  
now only need to split OS windows to view multiple kakoune buffers at a time  
or to view kakoune and some other TUI application
- potential to replace . /dev/stdin with a script to expand command abbreviations or user json shorthand etc.

Limitations

- no command prompt
  - run pwd
  - show somewhere in kakoune status line?  
most of my user scripts do not need to be sensitive to the directory they run from  
have removed some unnecessary directory sensitivities, streamlining my scripts

- haven’t figured out how to execute shell read under kakoune  
write shell scripts to fail with error message instead of requesting clarification via read  
add extra command line parameters to scripts to replace read prompts  
I find this to be a good design pattern to follow anyway  
most generic commands can adapt: eg sudo password prompts can be supplied through stdin  
loop with human intervention by emitting a command list into the buffer then  
Execute and check off entries in the list manually from the kakoune buffer
  - more flexible than a read loop with user intervention in bash

- must pipe output from long running background commands to file so that kakoune releases the process and returns to the UI  
this also turns out to be good design because stdout and stderr output was getting lost amoung the dozen kitty tabs I had open
- highlighting is different under kakoune and bash  
shell scripts that want to highlight must determine if they are running under kakoune or shell and emit output accordingly  
kak-ansi plugin should also work. e.g. for json where kakoune regex highlighting is incomplete
- kakoune command completion is not as good as vanilla bash completion  
design user scripts to minimize need for completion  
configure user scripts to emit output that feeds into each other
- no bash history at least under Debian 13 where kakoune invokes dash not bash  
save the kakoune buffer containing important shell commands instead…
