struct: standard file structure (#11)

* mass change. staged, not tested

* still mass changed without test

* bug fix

* bug fix
This commit is contained in:
2022-08-26 20:43:00 +08:00
committed by GitHub
parent f313a6887e
commit 8782121dcc
9 changed files with 220 additions and 201 deletions

90
.zshrc2
View File

@@ -68,46 +68,32 @@ antigen theme ${ZSH_THEME:-ys}
antigen apply
# end of antigen config
# functions
# env
export DOTFILES=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
export PATH=$PATH:$DOTFILES/scripts
SUDO=''
if (( $EUID != 0 )); then
SUDO='sudo'
fi
# alias
alias "pls"='sudo $(fc -ln -1)'
alias "se"='sudo -sE'
alias "pbd"='ping baidu.com'
alias "p114"='ping 114.114.114.114'
alias "p666"='ping6 2001:da8::666'
case $(bash "$DOTFILES/tools/common.sh" get_os_type) in
macos ) alias l='ls -lAGh -D "%y-%m-%d %H:%M"' ;;
* ) alias l='ls -lAGh --time-style="+%y-%m-%d %H:%M"' ;;
esac
get_os_type() {
case "$(uname -s)" in
Darwin*) ans="MacOS";;
CYGWIN*) ans="Cygwin";;
MSYS* ) ans="MSYS";;
Linux* ) ans="Linux";;
*) ans="unknown";;
esac
echo $ans | tr '[:upper:]' '[:lower:]'
}
get_linux_dist() {
if [ -f /etc/os-release ]; then
. /etc/os-release
ans=$ID
elif type lsb_release >/dev/null 2>&1; then
ans=$(lsb_release -si)
elif [ -f /etc/lsb-release ]; then
. /etc/lsb-release
ans=$DISTRIB_ID
elif [ -f /etc/debian_version ]; then
ans=Debian
elif [ -f /etc/SuSe-release ]; then
ans=SUSE
elif [ -f /etc/redhat-release ]; then
ans=RedHat
else
ans=unknown
fi
echo $ans | tr '[:upper:]' '[:lower:]'
}
# key bindings
bindkey "^b" beginning-of-line
bindkey "^e" end-of-line
bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
bindkey "^[[1~" beginning-of-line
bindkey "^[[4~" end-of-line
bindkey "^[OH" beginning-of-line
bindkey "^[OF" end-of-line
# dfs
dfs()
{
case $1 in
@@ -129,37 +115,7 @@ dfs()
echo 'Done. Please open a new shell to see the changes.'
;;
cd ) cd "$DOTFILES" ;;
log ) "$DOTFILES/tools/post-log.py" "$2" ;;
log ) "$DOTFILES/tools/common.sh" "post_log" "INFO" "dfs" "$2" ;;
* ) echo "unknown command \"$1\". available: update, force-update, version, reset, cd, log" ;;
esac
}
dogo()
{
if [[ -z "$1" || "$1" =~ "-h|--help" ]]; then
echo "usage: dogo <container>"
else
$SUDO docker exec -it $1 zsh
fi
}
# alias
alias "pls"='sudo $(fc -ln -1)'
alias "se"='sudo -sE'
alias "pbd"='ping baidu.com'
alias "p114"='ping 114.114.114.114'
alias "p666"='ping6 2001:da8::666'
case $(get_os_type) in
macos ) alias l='ls -lAGh -D "%y-%m-%d %H:%M"' ;;
* ) alias l='ls -lAGh --time-style="+%y-%m-%d %H:%M"' ;;
esac
# key bindings
bindkey "^b" beginning-of-line
bindkey "^e" end-of-line
bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
bindkey "^[[1~" beginning-of-line
bindkey "^[[4~" end-of-line
bindkey "^[OH" beginning-of-line
bindkey "^[OF" end-of-line