mirror of
https://github.com/DictXiong/dotfiles.git
synced 2025-07-07 17:40:30 +08:00
still mass changed without test
This commit is contained in:
parent
75c67dabc5
commit
e71cbd9bf4
77
.zshrc2
77
.zshrc2
@ -68,80 +68,9 @@ antigen theme ${ZSH_THEME:-ys}
|
|||||||
antigen apply
|
antigen apply
|
||||||
# end of antigen config
|
# end of antigen config
|
||||||
|
|
||||||
# functions
|
# env
|
||||||
export DOTFILES=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
export DOTFILES=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
||||||
|
export PATH=$PATH:$DOTFILES/scripts
|
||||||
SUDO=''
|
|
||||||
if (( $EUID != 0 )); then
|
|
||||||
SUDO='sudo'
|
|
||||||
fi
|
|
||||||
|
|
||||||
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:]'
|
|
||||||
}
|
|
||||||
|
|
||||||
dfs()
|
|
||||||
{
|
|
||||||
case $1 in
|
|
||||||
update ) "$DOTFILES/update.sh" ;;
|
|
||||||
force-update ) (
|
|
||||||
cd "$DOTFILES"
|
|
||||||
git fetch --all
|
|
||||||
ref=$(git symbolic-ref --short HEAD 2> /dev/null) || ref=$(git rev-parse --short HEAD 2> /dev/null) || return 0
|
|
||||||
for b in $(git for-each-ref refs/heads --format='%(refname)') ; do git checkout ${b#refs/heads/} ; git pull --ff-only ; done
|
|
||||||
git checkout -c advice.detachedHead=false $ref)
|
|
||||||
;;
|
|
||||||
version ) (cd "$DOTFILES" && git rev-parse HEAD) ;;
|
|
||||||
reset )
|
|
||||||
antigen reset 1> /dev/null
|
|
||||||
rm -rf $HOME/.antigen
|
|
||||||
"$DOTFILES/install.sh" -r
|
|
||||||
dfs update
|
|
||||||
"$DOTFILES/install.sh" -i
|
|
||||||
echo 'Done. Please open a new shell to see the changes.'
|
|
||||||
;;
|
|
||||||
cd ) cd "$DOTFILES" ;;
|
|
||||||
log ) "$DOTFILES/tools/post-log.py" "$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
|
||||||
alias "pls"='sudo $(fc -ln -1)'
|
alias "pls"='sudo $(fc -ln -1)'
|
||||||
@ -149,7 +78,7 @@ alias "se"='sudo -sE'
|
|||||||
alias "pbd"='ping baidu.com'
|
alias "pbd"='ping baidu.com'
|
||||||
alias "p114"='ping 114.114.114.114'
|
alias "p114"='ping 114.114.114.114'
|
||||||
alias "p666"='ping6 2001:da8::666'
|
alias "p666"='ping6 2001:da8::666'
|
||||||
case $(get_os_type) in
|
case $(bash "$DOTFILES/tools/common.sh" get_os_type) in
|
||||||
macos ) alias l='ls -lAGh -D "%y-%m-%d %H:%M"' ;;
|
macos ) alias l='ls -lAGh -D "%y-%m-%d %H:%M"' ;;
|
||||||
* ) alias l='ls -lAGh --time-style="+%y-%m-%d %H:%M"' ;;
|
* ) alias l='ls -lAGh --time-style="+%y-%m-%d %H:%M"' ;;
|
||||||
esac
|
esac
|
||||||
|
28
scripts/dfs
Executable file
28
scripts/dfs
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
||||||
|
DOTFILES=${DOTFILES:-$( cd "$THIS_DIR/.." && pwd )}
|
||||||
|
source "$DOTFILES/tools/common.sh"
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
update ) "$DOTFILES/update.sh" ;;
|
||||||
|
force-update ) (
|
||||||
|
cd "$DOTFILES"
|
||||||
|
git fetch --all
|
||||||
|
ref=$(git symbolic-ref --short HEAD 2> /dev/null) || ref=$(git rev-parse --short HEAD 2> /dev/null) || return 0
|
||||||
|
for b in $(git for-each-ref refs/heads --format='%(refname)') ; do git checkout ${b#refs/heads/} ; git pull --ff-only ; done
|
||||||
|
git checkout -c advice.detachedHead=false $ref)
|
||||||
|
;;
|
||||||
|
version ) (cd "$DOTFILES" && git rev-parse HEAD) ;;
|
||||||
|
reset )
|
||||||
|
antigen reset 1> /dev/null
|
||||||
|
rm -rf $HOME/.antigen
|
||||||
|
"$DOTFILES/install.sh" -r
|
||||||
|
dfs update
|
||||||
|
"$DOTFILES/install.sh" -i
|
||||||
|
echo 'Done. Please open a new shell to see the changes.'
|
||||||
|
;;
|
||||||
|
cd ) cd "$DOTFILES" ;;
|
||||||
|
log ) "$DOTFILES/tools/post-log.py" "$2" ;;
|
||||||
|
* ) echo "unknown command \"$1\". available: update, force-update, version, reset, cd, log" ;;
|
||||||
|
esac
|
11
scripts/dogo
Executable file
11
scripts/dogo
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
||||||
|
DOTFILES=${DOTFILES:-$( cd "$THIS_DIR/.." && pwd )}
|
||||||
|
source "$DOTFILES/tools/common.sh"
|
||||||
|
|
||||||
|
if [[ -z "$1" || "$1" =~ "-h|--help" ]]; then
|
||||||
|
fmt_info "usage: dogo <container>"
|
||||||
|
else
|
||||||
|
$SUDO docker exec -it $1 zsh
|
||||||
|
fi
|
@ -1,7 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
||||||
|
|
||||||
export DOTFILES=$( cd "$THIS_DIR/.." && pwd )
|
export DOTFILES=$( cd "$THIS_DIR/.." && pwd )
|
||||||
|
|
||||||
SUDO=''
|
SUDO=''
|
||||||
@ -100,7 +99,6 @@ setup_color() {
|
|||||||
FMT_BOLD=$(printf '\033[1m')
|
FMT_BOLD=$(printf '\033[1m')
|
||||||
FMT_RESET=$(printf '\033[0m')
|
FMT_RESET=$(printf '\033[0m')
|
||||||
}
|
}
|
||||||
setup_color
|
|
||||||
# END of color settings
|
# END of color settings
|
||||||
|
|
||||||
ask_for_yN()
|
ask_for_yN()
|
||||||
@ -119,3 +117,41 @@ post_log()
|
|||||||
{
|
{
|
||||||
python3 "${DOTFILES}/tools/log.py" "[$1] $2: $3"
|
python3 "${DOTFILES}/tools/log.py" "[$1] $2: $3"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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:]'
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||||
|
$1
|
||||||
|
else
|
||||||
|
setup_color
|
||||||
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user