mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-25 04:24:48 +03:00
Integration with GNU screen; based on tmux.kak
- Hack: kak sets `/proc/self/fd/0 -> /dev/null`. Get the client process tty because Screen needs to know the controlling terminal. Else Screen will use the last known tty and will open new windows on a different terminal if one is connected.
This commit is contained in:
parent
9c964e97f0
commit
d9a574acd5
50
rc/base/screen.kak
Normal file
50
rc/base/screen.kak
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# http://gnu.org/software/screen/
|
||||||
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||||
|
|
||||||
|
hook global KakBegin .* %{
|
||||||
|
%sh{
|
||||||
|
[ -z "kak_client_env_$STY" ] && exit
|
||||||
|
echo "
|
||||||
|
alias global focus screen-focus
|
||||||
|
alias global new screen-new-vertical
|
||||||
|
"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def screen-new-vertical -params .. -command-completion -docstring "Create a new vertical region" %{
|
||||||
|
%sh{
|
||||||
|
|
||||||
|
tty="$(ps -o tty ${kak_client_pid} | tail -n 1)"
|
||||||
|
screen -X eval 'split -h' 'focus down' "screen kak -c \"${kak_session}\" -e \"$*\"" < "/dev/$tty"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def screen-new-horizontal -params .. -command-completion -docstring "Create a new horizontal region" %{
|
||||||
|
%sh{
|
||||||
|
tty="$(ps -o tty ${kak_client_pid} | tail -n 1)"
|
||||||
|
screen -X eval 'split -v' 'focus right' "screen kak -c \"${kak_session}\" -e \"$*\"" < "/dev/$tty"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def screen-new-window -params .. -command-completion -docstring "Create a new window" %{
|
||||||
|
%sh{
|
||||||
|
tty="$(ps -o tty ${kak_client_pid} | tail -n 1)"
|
||||||
|
screen -X screen kak -c "${kak_session}" -e "$*" < "/dev/$tty"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def -docstring %{screen-focus [<client>]: focus the given client
|
||||||
|
If no client is passed then the current one is used} \
|
||||||
|
-params ..1 -client-completion \
|
||||||
|
screen-focus %{ %sh{
|
||||||
|
if [ $# -eq 1 ]; then
|
||||||
|
printf %s\\n "
|
||||||
|
evaluate-commands -client '$1' %{ %sh{
|
||||||
|
screen -X focus
|
||||||
|
}}"
|
||||||
|
elif [ -n "kak_client_env_$STY" ]; then
|
||||||
|
tty="$(ps -o tty ${kak_client_pid} | tail -n 1)"
|
||||||
|
screen -X select "$kak_client_env_WINDOW" < "$/dev/$tty"
|
||||||
|
fi
|
||||||
|
} }
|
Loading…
Reference in New Issue
Block a user