-
Notifications
You must be signed in to change notification settings - Fork 10
/
.anyrc
50 lines (40 loc) · 1.34 KB
/
.anyrc
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
46
47
48
49
50
# This example is compatible with bash and zsh
CURR_SHELL="$(readlink /proc/$$/exe)"
# For before loading shell
## bash
bash() {
$(sh -c 'which bash') --rcfile "${ANYRC_HOME}/.bashrc"
}
## zsh
export ZDOTDIR="${ANYRC_HOME}"
# For after loading shell
## vim
export VIMINIT="let \$MYVIMRC='${ANYRC_HOME}/.vimrc' | source \${MYVIMRC}"
## tmux
tmux() {
local TMUX_DIR="/tmp/anyrc.tmux.$(whoami)"
[ ! -d "${TMUX_DIR}" ] && rm -rf "${TMUX_DIR}"
mkdir -p "${TMUX_DIR}"
chmod 700 "${TMUX_DIR}"
# Copy all of anyrc for inside of tmux
'cp' -rf "${ANYRC_ROOT}/." "${TMUX_DIR}" &> /dev/null
# If ssh-agent is enabled, use a static path
[ -n "${SSH_AUTH_SOCK}" ] && ln -sf "${SSH_AUTH_SOCK}" "${TMUX_DIR}/agent"
DANYRC_NAME="${DANYRC_NAME}" \
DANYRCD_NAME="${DANYRCD_NAME}" \
ANYRC_ROOT="${TMUX_DIR}" \
ANYRC_DANYRC="${TMUX_DIR}/${DANYRC_NAME}" \
ANYRC_DANYRCD="${TMUX_DIR}/${DANYRCD_NAME}" \
ANYRC_HOME="${TMUX_DIR}/${DANYRCD_NAME}" \
VIMINIT="let \$MYVIMRC='${TMUX_DIR}/${DANYRCD_NAME}/.vimrc' | source \${MYVIMRC}" \
ZDOTDIR="${TMUX_DIR}/${DANYRCD_NAME}" \
SSH_AUTH_SOCK="${TMUX_DIR}/agent" \
PATH="${TMUX_DIR}:${PATH}" \
$(sh -c 'which tmux') -2 \
-f "${TMUX_DIR}/${DANYRCD_NAME}/.tmux.conf" \
-S "${TMUX_DIR}/tmuxserver" "$@"
}
## git
git() {
HOME="${ANYRC_HOME}" $(sh -c 'which git') "$@"
}