Merge remote-tracking branch '2xsaiko/outgoing/newlines-for-iterm2'
This commit is contained in:
commit
760a45556c
|
@ -8,18 +8,14 @@ evaluate-commands %sh{
|
|||
[ -z "${kak_opt_windowing_modules}" ] || [ "$TERM_PROGRAM" = "iTerm.app" ] || echo 'fail iTerm not detected'
|
||||
}
|
||||
|
||||
define-command -hidden -params 2.. iterm-terminal-split-impl %{
|
||||
define-command -hidden -params 2.. iterm-terminal-impl %{
|
||||
nop %sh{
|
||||
direction="$1"
|
||||
shift
|
||||
# join the arguments as one string for the shell execution (see x11.kak)
|
||||
args=$(
|
||||
for i in "$@"; do
|
||||
if [ "$i" = '' ]; then
|
||||
printf "'' "
|
||||
else
|
||||
printf %s "$i" | sed -e "s|'|'\\\\''|g; s|^|'|; s|$|' |"
|
||||
fi
|
||||
printf "'%s' " "$(printf %s "$i" | sed "s|'|'\\\\''|g")"
|
||||
done
|
||||
)
|
||||
|
||||
|
@ -34,12 +30,26 @@ define-command -hidden -params 2.. iterm-terminal-split-impl %{
|
|||
esc_path=$(do_esc "$PATH")
|
||||
esc_tmp=$(do_esc "$TMPDIR")
|
||||
cmd="env PATH='${esc_path}' TMPDIR='${esc_tmp}' $escaped"
|
||||
osascript \
|
||||
-e "tell application \"iTerm\"" \
|
||||
-e " tell current session of current window" \
|
||||
-e " tell (split ${direction} with same profile command \"${cmd}\") to select" \
|
||||
-e " end tell" \
|
||||
-e "end tell" >/dev/null
|
||||
if [ "$direction" = 'tab' ]; then
|
||||
osascript \
|
||||
-e "tell application \"iTerm\"" \
|
||||
-e " tell current window" \
|
||||
-e " create tab with default profile command \"${cmd}\"" \
|
||||
-e " end tell" \
|
||||
-e "end tell" >/dev/null
|
||||
elif [ "$direction" = 'window' ]; then
|
||||
osascript \
|
||||
-e "tell application \"iTerm\"" \
|
||||
-e " create window with default profile command \"${cmd}\"" \
|
||||
-e "end tell" >/dev/null
|
||||
else
|
||||
osascript \
|
||||
-e "tell application \"iTerm\"" \
|
||||
-e " tell current session of current window" \
|
||||
-e " tell (split ${direction} with same profile command \"${cmd}\") to select" \
|
||||
-e " end tell" \
|
||||
-e "end tell" >/dev/null
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +58,7 @@ iterm-terminal-vertical <program> [<arguments>]: create a new terminal as an ite
|
|||
The current pane is split into two, left and right
|
||||
The program passed as argument will be executed in the new terminal'\
|
||||
%{
|
||||
iterm-terminal-split-impl 'vertically' %arg{@}
|
||||
iterm-terminal-impl 'vertically' %arg{@}
|
||||
}
|
||||
complete-command iterm-terminal-vertical shell
|
||||
|
||||
|
@ -57,7 +67,7 @@ iterm-terminal-horizontal <program> [<arguments>]: create a new terminal as an i
|
|||
The current pane is split into two, top and bottom
|
||||
The program passed as argument will be executed in the new terminal'\
|
||||
%{
|
||||
iterm-terminal-split-impl 'horizontally' %arg{@}
|
||||
iterm-terminal-impl 'horizontally' %arg{@}
|
||||
}
|
||||
complete-command iterm-terminal-horizontal shell
|
||||
|
||||
|
@ -65,26 +75,7 @@ define-command iterm-terminal-tab -params 1.. -docstring '
|
|||
iterm-terminal-tab <program> [<arguments>]: create a new terminal as an iterm tab
|
||||
The program passed as argument will be executed in the new terminal'\
|
||||
%{
|
||||
nop %sh{
|
||||
# see above
|
||||
args=$(
|
||||
for i in "$@"; do
|
||||
if [ "$i" = '' ]; then
|
||||
printf "'' "
|
||||
else
|
||||
printf %s "$i" | sed -e "s|'|'\\\\''|g; s|^|'|; s|$|' |"
|
||||
fi
|
||||
done
|
||||
)
|
||||
escaped=$(printf %s "$args" | sed -e 's|\\|\\\\|g; s|"|\\"|g')
|
||||
cmd="env PATH='${PATH}' TMPDIR='${TMPDIR}' $escaped"
|
||||
osascript \
|
||||
-e "tell application \"iTerm\"" \
|
||||
-e " tell current window" \
|
||||
-e " create tab with default profile command \"${cmd}\"" \
|
||||
-e " end tell" \
|
||||
-e "end tell" >/dev/null
|
||||
}
|
||||
iterm-terminal-impl 'tab' %arg{@}
|
||||
}
|
||||
complete-command iterm-terminal-tab shell
|
||||
|
||||
|
@ -92,24 +83,7 @@ define-command iterm-terminal-window -params 1.. -docstring '
|
|||
iterm-terminal-window <program> [<arguments>]: create a new terminal as an iterm window
|
||||
The program passed as argument will be executed in the new terminal'\
|
||||
%{
|
||||
nop %sh{
|
||||
# see above
|
||||
args=$(
|
||||
for i in "$@"; do
|
||||
if [ "$i" = '' ]; then
|
||||
printf "'' "
|
||||
else
|
||||
printf %s "$i" | sed -e "s|'|'\\\\''|g; s|^|'|; s|$|' |"
|
||||
fi
|
||||
done
|
||||
)
|
||||
escaped=$(printf %s "$args" | sed -e 's|\\|\\\\|g; s|"|\\"|g')
|
||||
cmd="env PATH='${PATH}' TMPDIR='${TMPDIR}' $escaped"
|
||||
osascript \
|
||||
-e "tell application \"iTerm\"" \
|
||||
-e " create window with default profile command \"${cmd}\"" \
|
||||
-e "end tell" >/dev/null
|
||||
}
|
||||
iterm-terminal-impl 'window' %arg{@}
|
||||
}
|
||||
complete-command iterm-terminal-window shell
|
||||
|
||||
|
|
|
@ -17,11 +17,7 @@ define-command screen-terminal-impl -hidden -params 3.. %{
|
|||
# see x11.kak for what this achieves
|
||||
args=$(
|
||||
for i in "$@"; do
|
||||
if [ "$i" = '' ]; then
|
||||
printf "'' "
|
||||
else
|
||||
printf %s "$i" | sed -e "s|'|'\\\\''|g; s|^|'|; s|$|' |"
|
||||
fi
|
||||
printf "'%s' " "$(printf %s "$i" | sed "s|'|'\\\\''|g")"
|
||||
done
|
||||
)
|
||||
screen -X screen sh -c "${args} ; screen -X remove" < "/dev/$tty"
|
||||
|
|
Loading…
Reference in New Issue
Block a user