-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtcide_vim
executable file
·45 lines (39 loc) · 1.31 KB
/
tcide_vim
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
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
# Opens a tmux session with 3 panes: vim, twilight-commander, terminal.
# Hitting the file_action key (default: return) on a file entry opens it in a new vim tab.
# You need to compile vim with the clientserver option:
# git clone https://github.com/vim/vim.git
# cd vim/src
# make distclean
# ./configure +clientserver
# make
# sudo make install
if [ -z "$1" ]; then
INPUT_DIR='.'
elif [ -d "$1" ]; then
INPUT_DIR="$1"
elif [ -f "$1" ]; then
INPUT_DIR="$(dirname "$1")"
else
echo "tcide: opens a tmux session with vim and integrated twilight-commander"
echo "usage: tcide [directory or file]"
exit 1
fi
DIRNAME="$(readlink -f "$INPUT_DIR")"
BASENAME="$(basename "$DIRNAME")"
echo "opening $DIRNAME"
# TODO: check for used vim servers with 'vim --serverlist'?
# tmux does not allow reuse of session names, so ths seems unecessary
tmux -2 new-session -x "$(tput cols)" -y "$(tput lines)" \
-s "$DIRNAME" \
-d twilight-commander \
--behavior.file_action="vim --servername $DIRNAME --remote-tab %s" \
--setup.working_dir="$DIRNAME" \
\; \
split-window -h "vim --servername $DIRNAME" \; \
split-window -v \; \
resize-pane -t 0 -x 30 \; \
resize-pane -t 2 -y 15 \; \
set-option set-titles on \; \
set-option set-titles-string "$BASENAME" \; \
attach