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() {
|
2021-12-17 07:44:20 +00:00
|
|
|
|
curl -s "https://cheat.sh/$1" | less -R
|
2021-11-06 16:50:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-12-17 07:39:37 +00:00
|
|
|
|
# Настройка mc для работы в терминале kitty
|
|
|
|
|
# Необходимо закрыть все экземпляры mc для текущего пользователя
|
|
|
|
|
# При вызове функции с параметром -f текущие настройки клавиш
|
|
|
|
|
# для работы mc в терминале kitty будут перезаписаны
|
2021-12-12 12:17:40 +00:00
|
|
|
|
mc-kitty-add() {
|
2021-12-12 16:28:51 +00:00
|
|
|
|
local mc_cfg="${HOME}/.config/mc/ini"
|
2021-12-12 12:17:40 +00:00
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|