experimental: custom zsh
This commit is contained in:
parent
26b960c63a
commit
9fdb1ba055
@ -1,5 +1,3 @@
|
||||
ZSH_THEME="ys-simple"
|
||||
|
||||
zstyle ':omz:update' mode reminder # just remind me to update when it's time
|
||||
|
||||
zstyle ':omz:update' frequency 13
|
||||
|
||||
7
files/zsh/10-theme.zsh
Normal file
7
files/zsh/10-theme.zsh
Normal file
@ -0,0 +1,7 @@
|
||||
ZSH_THEME="ys-simple"
|
||||
|
||||
HOST="VM-ubuntu"
|
||||
|
||||
HIST_STAMPS='yyyy-mm-dd'
|
||||
DISABLE_AUTO_TITLE='true'
|
||||
ZSH_THEME_TERM_TITLE_IDLE='%~'
|
||||
32
files/zsh/20-alias.zsh
Normal file
32
files/zsh/20-alias.zsh
Normal file
@ -0,0 +1,32 @@
|
||||
alias -s txt='nano'
|
||||
alias -s xz='tar -xvf'
|
||||
alias -s gz='tar -xzvf'
|
||||
alias -s tgz='tar -xzvf'
|
||||
alias -s zip='unzip'
|
||||
alias -s bz2='tar -xjvf'
|
||||
|
||||
alias cp='cp -i'
|
||||
alias cl='clear'
|
||||
alias ag='alias | grep'
|
||||
alias hg='history | grep'
|
||||
|
||||
alias ipl='sudo iptables -L -n'
|
||||
if [ -f "/etc/network/if-pre-up.d/iptables-load" ]; then
|
||||
alias ipe='sudo nano /etc/network/if-pre-up.d/iptables-load'
|
||||
alias ips='sudo /etc/network/if-pre-up.d/iptables-load'
|
||||
fi
|
||||
|
||||
command_exists() { command -v "$@" >/dev/null 2>&1; }
|
||||
|
||||
command_exists trash-put && alias rm='trash-put'
|
||||
command_exists batcat && alias cat='batcat'
|
||||
command_exists fdfind && alias fd='fdfind'
|
||||
|
||||
if command_exists eza; then
|
||||
alias e='eza -la'
|
||||
alias eb='eza -lab'
|
||||
alias et='eza -lT'
|
||||
alias ef='eza -lTa -BhHigSmu'
|
||||
fi
|
||||
|
||||
command_exists docker && alias gost='docker run --rm -p 9443:9443 --cpus=0.2 --memory=256mb gogost/gost -L socks5://nano:QpuwAqcsP8Xp@:9443'
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/zsh
|
||||
|
||||
__is_public_ipv4() {
|
||||
__zsh_is_public_ipv4() {
|
||||
local ip=$1
|
||||
if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
IFS='.' read -r -A ADDR <<< "$ip"
|
||||
@ -18,20 +18,20 @@ __is_public_ipv4() {
|
||||
fi
|
||||
}
|
||||
|
||||
__get_ipv4() {
|
||||
__zsh_get_ipv4() {
|
||||
local ipv4=$(ip route get 1.1.1.1 | head -1 | awk '{print $7}')
|
||||
if __is_public_ipv4 $ipv4; then echo "$ipv4"; return 0; fi
|
||||
if __zsh_is_public_ipv4 $ipv4; then echo "$ipv4"; return 0; fi
|
||||
ipv4=$(ip route get 1.1.1.1 | head -1 | awk '{print $NF}')
|
||||
if __is_public_ipv4 $ipv4; then echo "$ipv4"; return 0; fi
|
||||
if __zsh_is_public_ipv4 $ipv4; then echo "$ipv4"; return 0; fi
|
||||
ipv4=$(curl -4 -s ifconfig.me)
|
||||
if __is_public_ipv4 $ipv4; then echo "$ipv4"; return 0; fi
|
||||
if __zsh_is_public_ipv4 $ipv4; then echo "$ipv4"; return 0; fi
|
||||
ipv4=$(host -4 myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}')
|
||||
if __is_public_ipv4 $ipv4; then echo "$ipv4"; return 0; fi
|
||||
if __zsh_is_public_ipv4 $ipv4; then echo "$ipv4"; return 0; fi
|
||||
# echo "No public IPv4 address found"
|
||||
return 1
|
||||
}
|
||||
|
||||
__get_ipv6() {
|
||||
__zsh_get_ipv6() {
|
||||
if [[ "$(ip -6 route get 2001:4860:4860::8888 2>&1 | awk '{print $NF}')" == "unreachable" ]]; then
|
||||
echo "No IPv6 connectivity"
|
||||
return 1
|
||||
@ -46,7 +46,9 @@ __get_ipv6() {
|
||||
return 1
|
||||
}
|
||||
|
||||
__get_ip() {
|
||||
__get_ipv4
|
||||
__get_ipv6
|
||||
__zsh_get_ip() {
|
||||
__zsh_get_ipv4
|
||||
__zsh_get_ipv6
|
||||
}
|
||||
|
||||
alias net='__zsh_get_ip'
|
||||
22
files/zsh/80-environment.zsh
Normal file
22
files/zsh/80-environment.zsh
Normal file
@ -0,0 +1,22 @@
|
||||
# pip3
|
||||
export PATH=$PATH:$HOME/.local/bin
|
||||
command_exists trash-put && alias rm='trash-put'
|
||||
|
||||
# Docker
|
||||
# export DOCKER_HOST=unix:///run/user/500/docker.sock
|
||||
# export DOCKER_HOST=unix:///run/user/1000/docker.sock
|
||||
|
||||
# Yarn
|
||||
# export PATH=$PATH:$HOME/.yarn/bin
|
||||
|
||||
# Golang
|
||||
# export PATH=$PATH:/usr/local/go/bin
|
||||
# export PATH=$PATH:$HOME/.local/go/bin
|
||||
# export GOPROXY=https://goproxy.cn,direct
|
||||
|
||||
# Node.js, npm, nvm
|
||||
# export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node
|
||||
# export NVM_IOJS_ORG_MIRROR=https://npmmirror.com/mirrors/iojs
|
||||
|
||||
# WSL Xming
|
||||
# export DISPLAY=:0;
|
||||
6
files/zsh/90-other.zsh
Normal file
6
files/zsh/90-other.zsh
Normal file
@ -0,0 +1,6 @@
|
||||
_systemctl_unit_state() {
|
||||
typeset -gA _sys_unit_state
|
||||
_sys_unit_state=( $(__systemctl list-unit-files '$PREFIX*' | awk '{print $1, $2}') )
|
||||
}
|
||||
|
||||
alias lazy='~/.lazy/run.sh'
|
||||
11
init_priv.sh
11
init_priv.sh
@ -102,14 +102,19 @@ configure_zsh() {
|
||||
git_clone paulirish/git-open ~/.oh-my-zsh/custom/plugins/git-open --norecursive
|
||||
sudo apt install autojump -y
|
||||
|
||||
cp $scriptdir/files/zsh/ys-simple.zsh-theme ~/.oh-my-zsh/custom/themes/ys-simple.zsh-theme
|
||||
|
||||
if ! grep -Fxq "source ~/.zsh_init" ~/.zshrc; then
|
||||
local line_number=$(grep -n "source \$ZSH/oh-my-zsh.sh" .zshrc | cut -d : -f 1)
|
||||
sed -i "${line_number}i source ~/.zsh_init\n" .zshrc
|
||||
fi
|
||||
|
||||
cp $scriptdir/files/zsh/.zsh_init ~/.zsh_init
|
||||
local zsh_scriptdir=$scriptdir/files/zsh
|
||||
cp $scriptdir/files/zsh/.zsh_init ~/.zsh_init
|
||||
cp $scriptdir/files/zsh/10-theme.zsh ~/.oh-my-zsh/custom/
|
||||
cp $scriptdir/files/zsh/20-alias.zsh ~/.oh-my-zsh/custom/
|
||||
cp $scriptdir/files/zsh/50-function.zsh ~/.oh-my-zsh/custom/
|
||||
cp $scriptdir/files/zsh/80-environment.zsh ~/.oh-my-zsh/custom/
|
||||
cp $scriptdir/files/zsh/90-other.zsh ~/.oh-my-zsh/custom/
|
||||
cp $scriptdir/files/zsh/ys-simple.zsh-theme ~/.oh-my-zsh/custom/themes/
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@ -79,6 +79,8 @@ configure_nodejs() {
|
||||
# ============================================================
|
||||
|
||||
update_file $scriptdir/files/zsh/ys-simple.zsh-theme ~/.oh-my-zsh/custom/themes/ys-simple.zsh-theme
|
||||
update_file $scriptdir/files/zsh/.zsh_init ~/.zsh_init
|
||||
update_file $scriptdir/files/zsh/.zsh_init ~/.zsh_init
|
||||
# update_file $scriptdir/files/.user_utils ~/.user_utils
|
||||
update_authorized_keys
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user