bashrc_lastest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
function parse_git_dirty {
local git_status=$(git status 2> /dev/null);
local modify_file_num=0;
local commit_file_num=0;
local change_file_num=0;
local untracked_file_num=0;
#if [[ "${git_status}" =~ "nothing to commit, working tree clean" ]]; then
# echo ""
# exit 0
#fi
if [[ "${git_status}" =~ "Changes not staged for commit" ]]; then
# 有修改的文件
modify_file_num=$( git diff --name-only 2> /dev/null | wc -l | tr -d ' ' )
fi
if [[ "${git_status}" =~ "Changes to be committed" ]]; then
# 有要提交的文件
commit_file_num=$( git diff --cached --name-only 2> /dev/null | wc -l | tr -d ' ' )
fi
if [[ "${git_status}" =~ "Untracked files" ]]; then
# 存在改动的文件
change_file_num=$( cd $( git rev-parse --show-toplevel ); git ls-files --others --exclude-standard 2> /dev/null | wc -l | tr -d ' ' )
fi
#echo -e "\[\033[01;32m\]A:\[\033[01;31m\]${commit_file_num} \[\033[01;32m\]M:\[\033[01;31m\]${modify_file_num} \[\033[01;32m\]+:\[\033[01;31m\]${change_file_num}\[\033[01;31m\]";
# \[\033[0;32m\]A 由这个0;32m 将后面的字体都变成正常体(非粗体)
echo -e "\[\033[0;32m\]A:\[\033[31m\]${commit_file_num} \[\033[32m\]M:\[\033[31m\]${modify_file_num} \[\033[32m\]+:\[\033[31m\]${change_file_num}\[\033[31m\]";
}
function git_branch()
{
branch=$( git rev-parse --abbrev-ref HEAD 2>/dev/null )
if [ "${branch}" != "" ]; then
if [ "${branch}" = "(no branch)" ]; then
branch="($( git rev-parse --short HEAD )...)"
fi
# 本地与远端文件量差
## 获取远程仓库的最新信息,但不改变本地状态
#diff_file_num=$( git fetch origin 2>/dev/null; git diff HEAD..origin --name-only | wc -l | tr -d ' ' )
diff_file_num=$( git diff HEAD..origin --name-only | wc -l | tr -d ' ' )
echo -e "⎇ \[\033[01;33m\]${branch} \[\033[01;36m\][ $(parse_git_dirty) \[\033[01;36m\]] \[\033[0;32m\]↓:\[\033[31m\]${diff_file_num} \[\033[01;36m\]"
fi
}
function prompt_command {
PS1="\n\[\033[01;36m\][\u@\h\[\033[01;32m\] \w\[\033[01;36m\]]\[\033[01;36m\] $(git_branch)\[\033[00m\]\n\\$\[\033[00m\] "
}
# 关闭brew每次执行命令时的自动更新
export HOMEBREW_NO_AUTO_UPDATE=true
export PATH="/opt/homebrew/bin:$PATH"
[[ -r "/opt/homebrew/etc/profile.d/bash_completion.sh" ]] && . "/opt/homebrew/etc/profile.d/bash_completion.sh"
# PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"
alias l='gls -l'
alias ll='gls --color=auto -lh --time-style=+"%Y-%m-%d %H:%M:%S.%3N"'
alias la='gls --color=auto -lFah --time-style=+"%Y-%m-%d %H:%M:%S.%3N"'
#alias ll='gls --color=auto -lh --time-style=long-iso'
#alias la='gls --color=auto -lFah --time-style=long-iso'
alias cdxt="cd /Users/FengYLBook/DataStorage/XTransfer_Save"
alias cdxtgit="cd /Users/FengYLBook/DataStorage/XTransfer_Save/XTgit"
alias cdfsgit="cd /Users/FengYLBook/DataStorage/My_Info/FSGit"
alias cdso="cd /Users/FengYLBook/.ssh/socket"
alias cdgo="cd /Users/FengYLBook/DataStorage/My_Info/FSGit/GoCode"
alias cdob="cd /Users/FengYLBook/DataStorage/ObsidianNote"
alias rm-ssh='rm -rf ~/.ssh/socket/*'
alias cdde='cd /Users/FengYLBook/Desktop'
#alias rm="sudo mv $* ~/.Trash"
export PATH="/Users/FengYLBook/bin:$PATH"
# 先创建文件: .git-completion.bash
# 获取文件内容地址: https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
if \[ -f ~/.git-completion.bash \]; then
. ~/.git-completion.bash
fi
# go 环境配置
export GOROOT=/usr/local/go
export GOPATH="/Users/FengYLBook/DataStorage/GoWorkspace"
export GOBIN="/Users/FengYLBook/DataStorage/GoWorkspace/bin"
export GO111MODULE=on
export GOPROXY=https://goproxy.cn,direct
export PATH=$PATH:$GOROOT/bin:$GOBIN
complete -C /Users/FengYLBook/DataStorage/GoWorkspace/bin/gocomplete go
export PATH="/opt/homebrew/opt/mysql-client/bin:$PATH"
export HISTSIZE=100000
HISTTIMEFORMAT="%F %T "
alias python="/opt/homebrew/bin/python3"
alias pip="/opt/homebrew/bin/pip3.10"
export PATH="/opt/homebrew/opt/berkeley-db/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/berkeley-db/lib"
export CPPFLAGS="-I/opt/homebrew/opt/berkeley-db/include"
export PATH="/opt/homebrew/opt/ruby/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/ruby/lib"
export CPPFLAGS="-I/opt/homebrew/opt/ruby/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/ruby/lib/pkgconfig"
eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=$HOME/perl5)"
PROMPT_COMMAND=prompt_command
export CLICOLOR=1
export LSCOLORS=ExGxFxdaCxDaDahbadache
export BASH_SILENCE_DEPRECATION_WARNING=1
# 切换k8s集群
source $HOME/bin/sk-ln
function sk(){
option=$1
if [ -z "${option}" ]; then
# 不加后缀切换配置文件
[[ ${KUBECONFIG} == "$HOME/.kube/config.dev" ]]
if [ $? -ne 0 ]; then
export KUBECONFIG="$HOME/.kube/config.dev"
logger $? "切换: 本地 --> 默认"
else
export KUBECONFIG="$HOME/.kube/config.sit"
logger $? "切换: 阿里云测试 --> 默认"
fi
elif [ ${option} == "al" ]; then
export KUBECONFIG="$HOME/.kube/config.sit"
logger $? "切换: 阿里云测试 --> 默认"
elif [ ${option} == "tx" ]; then
export KUBECONFIG="$HOME/.kube/config.sitxt"
logger $? "切换: 腾讯云测试 --> 默认"
elif [ ${option} == "ai" ]; then
export KUBECONFIG="$HOME/.kube/config.aimode"
logger $? "切换: 算法测试集群 --> 默认"
elif [ ${option} == "fz" ]; then
export KUBECONFIG="$HOME/.kube/config.fz"
logger $? "切换: 仿真环境集群 --> 默认"
else
logger 1 "切换: 参数[$option] 未找到"
fi
}
export HOMEBREW_PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple #ckbrew
export HOMEBREW_API_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api #ckbrew
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles #ckbrew
eval $(/opt/homebrew/bin/brew shellenv) #ckbrew
# gem
export PATH="/opt/homebrew/lib/ruby/gems/3.1.0/bin:$PATH"
export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
# 禁用邮件提示
unset MAILCHECK
# 新建终端带上一个终端的路径
function cd {
builtin cd "$@" && pwd > ~/.lastdir
}
# Change to the last directory on a new terminal launch.
if [ -f ~/.lastdir ]; then
cd "$(cat ~/.lastdir)"
fi
本文由作者按照
CC BY 4.0
进行授权