mirror of
https://github.com/arcan1s/dotfiles.git
synced 2025-04-24 16:07:17 +00:00
fix links because exception capturing is not allowed in exante
add highlighting add vimpager
This commit is contained in:
parent
a44024a09d
commit
cc8f5e5759
2
links
2
links
@ -2,5 +2,3 @@
|
|||||||
.zshrc=zshrc
|
.zshrc=zshrc
|
||||||
.zsh=zsh-server
|
.zsh=zsh-server
|
||||||
.zlogout=zlogout
|
.zlogout=zlogout
|
||||||
.git=git
|
|
||||||
.gitconfig=gitconfig
|
|
||||||
|
147
tunctl
147
tunctl
@ -1,147 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# ssh config
|
|
||||||
IDENTITY="/root/.ssh/id_rsa"
|
|
||||||
SSH_SOCKET="/run/ssh-tunnel.sock"
|
|
||||||
SSH_USER="root"
|
|
||||||
# network config
|
|
||||||
LOCAL_IP="10.0.0.2"
|
|
||||||
PORTS="5432 20 21 10090:10100"
|
|
||||||
REMOTE_IP="10.0.0.1"
|
|
||||||
REMOTE_EXTIP="185.82.216.108"
|
|
||||||
REMOTE_EXTIF="eth0"
|
|
||||||
# daemon
|
|
||||||
SLEEPTIME="5m"
|
|
||||||
# notifications
|
|
||||||
FROM="server@repo.arcanis.name"
|
|
||||||
TO="darkarcanis@mail.ru"
|
|
||||||
SUBJECT="Server status report"
|
|
||||||
# cmds
|
|
||||||
IFCFG="/sbin/ifconfig"
|
|
||||||
IPT="/sbin/iptables"
|
|
||||||
MAIL="/usr/bin/mail"
|
|
||||||
SSH="/usr/bin/ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
|
||||||
-o TCPKeepAlive=yes -o ServerAliveInterval=600 -o ServerAliveCountMax=360 \
|
|
||||||
-o ControlMaster=auto -o PasswordAuthentication=no -i ${IDENTITY} "
|
|
||||||
|
|
||||||
|
|
||||||
function send_mail() {
|
|
||||||
local MESSAGE="${1}"
|
|
||||||
|
|
||||||
echo "${MESSAGE}" | "${MAIL}" -r "${FROM}" -s "${SUBJECT}" "${TO}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function do_start() {
|
|
||||||
[ -e "${SSH_SOCKET}" ] && rm -f "${SSH_SOCKET}"
|
|
||||||
${SSH} -M -S "${SSH_SOCKET}" -f -w 0:0 "${SSH_USER}"@"${REMOTE_EXTIP}" \
|
|
||||||
"${IFCFG}" tun0 "${REMOTE_IP}"/30 pointopoint "${LOCAL_IP}"
|
|
||||||
"${IFCFG}" tun0 "${LOCAL_IP}"/30 pointopoint "${REMOTE_IP}"
|
|
||||||
|
|
||||||
# send_mail "Tunnel has been started"
|
|
||||||
}
|
|
||||||
|
|
||||||
function do_stop() {
|
|
||||||
${SSH} -S "${SSH_SOCKET}" -O exit "${SSH_USER}"@"${REMOTE_EXTIP}"
|
|
||||||
[ -e "${SSH_SOCKET}" ] && rm -f "${SSH_SOCKET}"
|
|
||||||
|
|
||||||
# send_mail "Tunnel has been stoped"
|
|
||||||
}
|
|
||||||
|
|
||||||
function do_table() {
|
|
||||||
local PORT="${1}"
|
|
||||||
|
|
||||||
${SSH} "${SSH_USER}"@"${REMOTE_EXTIP}" \
|
|
||||||
"${IPT}" -t nat -A PREROUTING --dst "${REMOTE_EXTIP}" -p tcp --dport "${PORT}" -j DNAT --to-destination "${LOCAL_IP}"
|
|
||||||
${SSH} "${SSH_USER}"@"${REMOTE_EXTIP}" \
|
|
||||||
"${IPT}" -t nat -A POSTROUTING --dst "${LOCAL_IP}" -p tcp --dport "${PORT}" -j SNAT --to-source "${REMOTE_IP}"
|
|
||||||
${SSH} "${SSH_USER}"@"${REMOTE_EXTIP}" \
|
|
||||||
"${IPT}" -t nat -A OUTPUT --dst "${REMOTE_EXTIP}" -p tcp --dport "${PORT}" -j DNAT --to-destination "${LOCAL_IP}"
|
|
||||||
${SSH} "${SSH_USER}"@"${REMOTE_EXTIP}" \
|
|
||||||
"${IPT}" -I FORWARD 1 -i "${REMOTE_EXTIF}" -o tun0 -d "${LOCAL_IP}" -p tcp -m tcp --dport "${PORT}" -j ACCEPT
|
|
||||||
}
|
|
||||||
|
|
||||||
function do_clear_table() {
|
|
||||||
${SSH} "${SSH_USER}"@"${REMOTE_EXTIP}" "${IPT}" -t nat -F
|
|
||||||
${SSH} "${SSH_USER}"@"${REMOTE_EXTIP}" "${IPT}" -t nat -X
|
|
||||||
}
|
|
||||||
|
|
||||||
function do_add_table() {
|
|
||||||
local PORT
|
|
||||||
for PORT in ${PORTS}; do do_table "${PORT}"; done
|
|
||||||
}
|
|
||||||
|
|
||||||
function do_restart() {
|
|
||||||
if do_ping; then
|
|
||||||
do_clear_table
|
|
||||||
do_stop
|
|
||||||
fi
|
|
||||||
do_start
|
|
||||||
sleep 2
|
|
||||||
do_add_table
|
|
||||||
}
|
|
||||||
|
|
||||||
function do_ping() {
|
|
||||||
ping -c 4 -q "${REMOTE_IP}" &> /dev/null && return 0 || return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
function do_daemon() {
|
|
||||||
while true; do
|
|
||||||
sleep "${SLEEPTIME}"
|
|
||||||
echo "Check tunnel"
|
|
||||||
if ! do_ping; then
|
|
||||||
echo "Restart tunnel"
|
|
||||||
do_restart
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
case "${1}" in
|
|
||||||
start)
|
|
||||||
echo "Start tunnel"
|
|
||||||
do_ping && exit 0
|
|
||||||
do_start
|
|
||||||
sleep 2
|
|
||||||
do_add_table
|
|
||||||
;;
|
|
||||||
stop)
|
|
||||||
echo "Stop tunnel"
|
|
||||||
do_ping || exit 0
|
|
||||||
do_clear_table
|
|
||||||
do_stop
|
|
||||||
;;
|
|
||||||
restart)
|
|
||||||
echo "Restart tunnel"
|
|
||||||
if do_ping; then
|
|
||||||
do_restart
|
|
||||||
else
|
|
||||||
do_start
|
|
||||||
sleep 2
|
|
||||||
do_add_table
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
ping)
|
|
||||||
if do_ping; then
|
|
||||||
echo "Active"
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo "Inactive"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
check)
|
|
||||||
if ! do_ping; then
|
|
||||||
echo "Restart tunnel"
|
|
||||||
do_restart
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
daemon)
|
|
||||||
do_daemon
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Usage tunctl start|stop|restart|ping|check|daemon"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
exit 0
|
|
1
zsh-server/highlighting
Symbolic link
1
zsh-server/highlighting
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../zsh/highlighting
|
@ -1 +0,0 @@
|
|||||||
../zsh/prompt_server
|
|
27
zsh-server/prompt_server
Normal file
27
zsh-server/prompt_server
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# PROMPT && RPROMPT
|
||||||
|
if [[ $EUID == 0 ]]; then
|
||||||
|
# [root@host dir]#
|
||||||
|
PROMPT="%{$fg_bold[white]%}[%{$reset_color%}\
|
||||||
|
%{$fg_bold[red]%}%n%{$reset_color%}\
|
||||||
|
%{$fg_bold[white]%}@%{$reset_color%}\
|
||||||
|
%{$fg_no_bold[blue]%}%m %{$reset_color%}\
|
||||||
|
%{$fg_bold[yellow]%}%1/%{$reset_color%}\
|
||||||
|
%{$fg_bold[white]%}]# %{$reset_color%}"
|
||||||
|
else
|
||||||
|
# [user@host dir]$
|
||||||
|
PROMPT="%{$fg_bold[white]%}[%{$reset_color%}\
|
||||||
|
%{$fg_bold[green]%}%n%{$reset_color%}\
|
||||||
|
%{$fg_bold[white]%}@%{$reset_color%}\
|
||||||
|
%{$fg_no_bold[blue]%}%m %{$reset_color%}\
|
||||||
|
%{$fg_bold[yellow]%}%1/%{$reset_color%}\
|
||||||
|
%{$fg_bold[white]%}]$ %{$reset_color%}"
|
||||||
|
fi
|
||||||
|
precmd() {
|
||||||
|
# last command
|
||||||
|
returncode="%(?.%{$fg[green]%}.%{$fg[red]%})%?%{$resetcolor%}"
|
||||||
|
RPROMPT="%{$fg_bold[white]%}[%{$reset_color%}\
|
||||||
|
%{$fg_bold[cyan]%}%T%{$reset_color%}\
|
||||||
|
%{$fg_bold[white]%}][%{$reset_color%}"\
|
||||||
|
${returncode}\
|
||||||
|
"%{$fg_bold[white]%}]%{$reset_color%}"
|
||||||
|
}
|
1
zsh-server/use-vimpager
Symbolic link
1
zsh-server/use-vimpager
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../zsh/use-vimpager
|
1
zsh-server/vimpager
Symbolic link
1
zsh-server/vimpager
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../zsh/vimpager
|
1
zsh-server/zsh-syntax-highlighting
Symbolic link
1
zsh-server/zsh-syntax-highlighting
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../zsh/zsh-syntax-highlighting
|
@ -1,5 +1,9 @@
|
|||||||
# highlighting
|
# highlighting
|
||||||
source "/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|
if [[ -a "/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]]; then
|
||||||
|
source "/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|
||||||
|
else
|
||||||
|
source "$HOME/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|
||||||
|
fi
|
||||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)
|
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)
|
||||||
# brackets
|
# brackets
|
||||||
ZSH_HIGHLIGHT_STYLES[bracket-level-1]='fg=blue,bold'
|
ZSH_HIGHLIGHT_STYLES[bracket-level-1]='fg=blue,bold'
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
# PROMPT && RPROMPT
|
|
||||||
if [[ $EUID == 0 ]]; then
|
|
||||||
# [root@host dir]#
|
|
||||||
PROMPT="%{$fg_bold[white]%}[%{$reset_color%}\
|
|
||||||
%{$fg_bold[red]%}%n%{$reset_color%}\
|
|
||||||
%{$fg_bold[white]%}@%{$reset_color%}\
|
|
||||||
%{$fg_no_bold[blue]%}%m %{$reset_color%}\
|
|
||||||
%{$fg_bold[yellow]%}%1/%{$reset_color%}\
|
|
||||||
%{$fg_bold[white]%}]# %{$reset_color%}"
|
|
||||||
else
|
|
||||||
# [user@host dir]$
|
|
||||||
PROMPT="%{$fg_bold[white]%}[%{$reset_color%}\
|
|
||||||
%{$fg_bold[green]%}%n%{$reset_color%}\
|
|
||||||
%{$fg_bold[white]%}@%{$reset_color%}\
|
|
||||||
%{$fg_no_bold[blue]%}%m %{$reset_color%}\
|
|
||||||
%{$fg_bold[yellow]%}%1/%{$reset_color%}\
|
|
||||||
%{$fg_bold[white]%}]$ %{$reset_color%}"
|
|
||||||
fi
|
|
||||||
precmd() {
|
|
||||||
# last command
|
|
||||||
returncode="%(?.%{$fg[green]%}.%{$fg[red]%})%?%{$resetcolor%}"
|
|
||||||
RPROMPT="%{$fg_bold[white]%}[%{$reset_color%}\
|
|
||||||
%{$fg_bold[cyan]%}%T%{$reset_color%}\
|
|
||||||
%{$fg_bold[white]%}][%{$reset_color%}"\
|
|
||||||
${returncode}\
|
|
||||||
"%{$fg_bold[white]%}]%{$reset_color%}"
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
alias ssh-home="ssh -At repo 'ssh -A -p 5431 192.168.0.101'"
|
|
14
zsh/use-vimpager
Normal file
14
zsh/use-vimpager
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# use vimcat instead of cat
|
||||||
|
# till vimpager doesn't use pipe disable it
|
||||||
|
#alias cat='vimcat'
|
||||||
|
|
||||||
|
# use vimpager instead of less
|
||||||
|
# find vimpager
|
||||||
|
if which vimpager &> /dev/null; then
|
||||||
|
export PAGER="vimpager"
|
||||||
|
else
|
||||||
|
export PAGER="$HOME/.zsh/vimpager"
|
||||||
|
fi
|
||||||
|
alias less="$PAGER"
|
||||||
|
alias zless="$PAGER"
|
||||||
|
|
4371
zsh/vimpager
Normal file → Executable file
4371
zsh/vimpager
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
1
zsh/zsh-syntax-highlighting
Submodule
1
zsh/zsh-syntax-highlighting
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 57624bb9f64b88c633c03df986f73a45512eb60b
|
Loading…
Reference in New Issue
Block a user