2021-12-11 10:01:07 +00:00
|
|
|
# Обновление конфигурации zsh, менджера zcomet и плагинов
|
|
|
|
zu() {
|
|
|
|
git -C ~/.config/zsh pull && zcomet self-update && zcomet update
|
|
|
|
}
|
|
|
|
|
2021-11-06 16:50:38 +00:00
|
|
|
ch() {
|
|
|
|
curl -s "https://cheat.sh/$1" | less
|
|
|
|
}
|
|
|
|
|
|
|
|
exf() {
|
|
|
|
case "$1" in
|
|
|
|
*.tar.bz2) tar xjf "$1" ;;
|
|
|
|
*.tar.gz) tar xzf "$1" ;;
|
|
|
|
*.tar.xz) tar xJf "$1" ;;
|
|
|
|
*.tbz2) tar xjf "$1" ;;
|
|
|
|
*.tgz) tar xzf "$1" ;;
|
|
|
|
*.tar) tar xf "$1" ;;
|
|
|
|
*.zip) unzip "$1" ;;
|
|
|
|
*.7z) 7z x "$1" ;;
|
|
|
|
*.iso) 7z x "$1" ;;
|
|
|
|
*.rar) unrar x "$1" ;;
|
|
|
|
*) echo "'$1' cannot be extracted" ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
exfl() {
|
|
|
|
for F in "$@"
|
|
|
|
do
|
|
|
|
if [ -f "$F" ]; then
|
|
|
|
exf "$F"
|
|
|
|
else
|
|
|
|
echo "'$F' is not a valid file"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
exd() {
|
|
|
|
case "$1" in
|
|
|
|
*.tar.bz2) b=${1%.tar.bz2}; mkdir -p "$b">/dev/null; tar xjf "$1" -C "$b" ;;
|
|
|
|
*.tar.gz) b=${1%.tar.gz}; mkdir -p "$b">/dev/null; tar xzf "$1" -C "$b" ;;
|
|
|
|
*.tar.xz) b=${1%.tar.xz}; mkdir -p "$b">/dev/null; tar xJf "$1" -C "$b" ;;
|
|
|
|
*.tbz2) b=${1%.tbz2}; mkdir -p "$b">/dev/null; tar xjf "$1" -C "$b" ;;
|
|
|
|
*.tgz) b=${1%.tgz}; mkdir -p "$b">/dev/null; tar xzf "$1" -C "$b" ;;
|
|
|
|
*.tar) b=${1%.tar}; mkdir -p "$b">/dev/null; tar xf "$1" -C "$b" ;;
|
|
|
|
*.zip) b=${1%.zip}; unzip "$1" -d "$b" ;;
|
|
|
|
*.7z) b=${1%.7z}; 7z x -o"$b" "$1" ;;
|
|
|
|
*.iso) b=${1%.iso}; 7z x -o"$b" "$1" ;;
|
|
|
|
*.rar) b=${1%.rar}; rar x "$1" "$b" ;;
|
|
|
|
*) echo "'$1' cannot be extracted" ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
exdl() {
|
|
|
|
for F in "$@"
|
|
|
|
do
|
|
|
|
if [ -f "$F" ]; then
|
|
|
|
exd "$F"
|
|
|
|
else
|
|
|
|
echo "'$F' is not a valid file"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
2021-12-11 09:10:09 +00:00
|
|
|
|
|
|
|
psgrep() {
|
|
|
|
ps aux | grep "${1:-.}" | grep -v grep
|
|
|
|
}
|
|
|
|
|
|
|
|
# Kills any process that matches a regexp passed to it
|
|
|
|
killit() {
|
|
|
|
ps aux | grep -v "grep" | grep "$@" | awk '{print $2}' | xargs sudo kill
|
|
|
|
}
|
|
|
|
|
|
|
|
# gather external ip address
|
|
|
|
geteip() {
|
|
|
|
curl -s -S -4 https://icanhazip.com
|
|
|
|
curl -s -S -6 https://icanhazip.com
|
|
|
|
}
|
|
|
|
|
|
|
|
# determine local IP address(es)
|
|
|
|
getip() {
|
|
|
|
if (( ${+commands[ip]} )); then
|
|
|
|
ip addr | awk '/inet /{print $2}' | command grep -v 127.0.0.1
|
|
|
|
else
|
|
|
|
ifconfig | awk '/inet /{print $2}' | command grep -v 127.0.0.1
|
|
|
|
fi
|
|
|
|
}
|
2021-12-12 12:17:40 +00:00
|
|
|
|
|
|
|
# Автоматическая установка описания терминала xterm-kitty
|
|
|
|
kitty-install-terminfo() {
|
|
|
|
if [[ "x${TERM}" = "xxterm-kitty" ]]; then
|
|
|
|
if ! infocmp "xterm-kitty" > /dev/null 2>&1 ; then
|
|
|
|
if ! sudo apt-get install kitty-terminfo > /dev/null 2>&1 ; then
|
|
|
|
mkdir -p "${HOME}/.terminfo/x"
|
|
|
|
cp -ap "${ZDOTDIR}/terminfo/xterm-kitty" "${HOME}/.terminfo/x"
|
|
|
|
fi
|
|
|
|
echo "Terminal description for xterm-kitty was installed."
|
|
|
|
echo "Close terminal and start again."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Настройка mc для работы в kitty (mc не должен быть запущен)
|
|
|
|
mc-kitty-add() {
|
|
|
|
local mc_cfg="${HOME}/.config/mc/ini.test"
|
|
|
|
local mc_term="${ZDOTDIR}/terminfo/mc-kitty.ini"
|
|
|
|
|
|
|
|
[[ "x$1" == "x-f" ]] && sed -i '/\[terminal:xterm-kitty\]/,/^$/{d}' "${mc_cfg}"
|
|
|
|
if [ -w "${mc_cfg}" -a -r "${mc_term}" ]; then
|
|
|
|
if ! grep -qF "[terminal:xterm-kitty]" "${mc_cfg}" ; then
|
|
|
|
cat "${mc_term}" >> "${mc_cfg}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|