aboutsummaryrefslogtreecommitdiff
path: root/autoload/window.kak
blob: 4ea44d3cba4b208af51f5f0c7251b36b9b9dd50b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
declare-user-mode win
map global normal <c-w> ':enter-user-mode win<ret>' -docstring 'Window mode'

map global win q ': quit<ret>' -docstring 'Quit'
map global win <c-q> ': quit<ret>' -docstring 'Quit'
map global win s ': tmux-terminal-horizontal kak -c %val{session}<ret>' -docstring 'Split vertical'
map global win v ': tmux-terminal-vertical kak -c %val{session}<ret>' -docstring 'Split horizontal'
map global win z ': wq<ret>' -docstring 'Write and quit'
map global win t ': switch-to-tools<ret>' -docstring 'Tools client'

def switch-to-tools %{
  terminal-singleton tools kak -e 'rename-client tools' -c %val{session}
}

def toolsclient %{
  rename-client main
  set global jumpclient main

  try %{ eval -client tools nop } catch %{
    switch-to-tools
    set global toolsclient tools
    focus main
  }
}

def terminal-singleton -params 2.. -docstring 'terminal-singleton <name> <command> [args...]' %{
  nop %sh{
    name="$1"; shift 1;
    export KAKOUNE_SESSION="$kak_session"
    export KAKOUNE_CLIENT="$kak_client"
    setsid -f "$kak_config/scripts/term.clj" singleton "$name" "$@" </dev/null >/dev/null 2>&1 &
  }
}