Merge branch 'master' into lenovo-y480

This commit is contained in:
2026-03-16 18:29:56 +08:00
15 changed files with 371 additions and 32 deletions

View File

@@ -23,18 +23,13 @@ HISTCONTROL=ignoreboth
# export CCACHE_DIR="/var/cache/ccache"
export GPG_TTY=$(tty)
export PATH="~/.local/bin${PATH:+:}$PATH"
export PATH="${HOME}/.local/bin${PATH:+:}$PATH"
alias ll="ls -l"
alias la="ls -a"
alias lh="ls -lh"
alias lha="ls -lha"
PROXY_SHELL_FILE="$(realpath ~/.bash_proxy.sh)"
if [[ -e $PROXY_SHELL_FILE ]] ; then
. $PROXY_SHELL_FILE
fi
if [[ "$TERM" == "linux" ]]; then
PS1="(tty) $PS1"
elif [[ "$TERM" == "fbterm" ]]; then
@@ -48,26 +43,17 @@ elif [[ "${TERM}" != "tmux-256color" ]] && [[ -z "${TERM_PROGRAM}" ]] && [[ -x $
tmux
fi
alias pip='function _pip() {
if [ $1 == "search" ]; then
pip_search "$2";
else pip "$@";
fi;
};_pip'
# bash completion error
if [[ -n $(type -t _comp__split_longopt) ]] && [[ -z $(type -t _split_longopt) ]]; then
alias _split_longopt="_comp__split_longopt"
fi
# pnpm
export PNPM_HOME="$(realpath ~/.local/share/pnpm)"
export PATH="$PNPM_HOME:$PATH"
# pnpm end
# tabtab source for packages
# uninstall by removing these lines
[ -f ~/.config/tabtab/bash/__tabtab.bash ] && . ~/.config/tabtab/bash/__tabtab.bash || true
clean-pnpm-node() {
if [[ -d "$PNPM_HOME" ]]; then
rm -f "$PNPM_HOME/nodejs_current"
rm -f "$PNPM_HOME/node"
rm -f "$PNPM_HOME/npm"
rm -f "$PNPM_HOME/npx"
for _ in ${HOME}/.bashrc.d/*; do
if [[ $_ == *.@(bash|sh) && -r $_ ]]; then
source "$_"
fi
}
done
if [[ -n "$(type -t mise-activate)" ]]; then
mise-activate
fi

View File

@@ -0,0 +1,11 @@
basedir=$(realpath -m $(dirname "${BASH_SOURCE[0]:-$0}"))
source "${basedir}/function.bash"
unset basedir
export JAVA_HOME="/opt/android-studio/jbr"
export ANDROID_HOME="${HOME}/Android/Sdk"
export NDK_HOME="$ANDROID_HOME/ndk/$(ls -1 $ANDROID_HOME/ndk)"
add-to-path "${ANDROID_HOME}/emulator" "${ANDROID_HOME}/platform-tools"

44
dot/.bashrc.d/fnm.bash Normal file
View File

@@ -0,0 +1,44 @@
basedir=$(realpath -m $(dirname "${BASH_SOURCE[0]:-$0}"))
source "${basedir}/function.bash"
unset basedir
if [[ -e "$(type -p fnm)" ]]; then
generate-bash-completion fnm "fnm completions --shell bash"
fnm-activate() {
hash -r
eval "$(fnm env --use-on-cd --version-file-strategy=recursive)"
export FNM_NODE_DIST_MIRROR="https://npmmirror.com/mirrors/node"
__fnmcd() {
\cd "$@" || return $?
unhash-command-in-dirs "$FNM_MULTISHELL_PATH"/bin
__fnm_use_if_file_found
}
}
fnm-deactivate() {
if [[ "$(type -t cd)" == "alias" ]]; then
unalias cd
fi
if [[ -z "$FNM_MULTISHELL_PATH" ]]; then
return 0
fi
local fnm_multishell="$(dirname "$FNM_MULTISHELL_PATH")"
local -a envs=$(compgen -v | grep '^FNM_')
local -a all_tmp_dir=("$fnm_multishell"/*)
local -a bin_paths=("$fnm_multishell"/*/bin)
remove-from-path "${bin_paths[@]}"
unhash-command-in-dirs "${bin_paths[@]}"
rm -rf "${all_tmp_dir[@]}"
local var
for var in $envs; do
unset "$var"
done
}
fi

136
dot/.bashrc.d/function.bash Normal file
View File

@@ -0,0 +1,136 @@
generate-bash-completion() {
local file="$1"
local command="$2"
if [[ -z "$file" || -z "$command" ]]; then
echo "usage: generate-bash-completion <file> <command>" >&2
echo "example: generate-bash-completion mycmd '_mycmd_completion'" >&2
return 1
fi
local completion_dir="${HOME}/.local/share/bash-completion/completions"
local completion_file="$(realpath -m "${completion_dir}/${file}")"
if [[ -d "$completion_dir" && ! -w "$completion_dir" ]]; then
echo "ERROR: has no permission to write to directory '${completion_dir}'" >&2
return 1
fi
if [[ ! -f "$completion_file" ]]; then
if ! mkdir -p "$completion_dir"; then
echo "ERROR: cannot create directory '$completion_dir'" >&2
return 1
fi
if ! bash -c "$command" > "$completion_file"; then
echo "ERROR: failed to execute command '$command'" >&2
rm -f "$completion_file"
return 1
fi
fi
}
add-to-path() {
if [[ $# -eq 0 ]]; then
echo "usage: add-to-path <path1> [path2 ...]" >&2
echo "example: add-to-path /usr/local/bin /tmp/my-dir" >&2
return 1
fi
local -a dirs=("$@")
local dir
local dir_normalized
local new_path="$PATH"
for dir in "${dirs[@]}"; do
[[ -z "$dir" ]] && continue
dir_normalized="${dir%/}"
if [[ ! -d "$dir_normalized" ]]; then
echo "WARNING: '${dir}' is not a valid directory, skipped." >&2
continue
fi
case ":${new_path}:" in
*":${dir_normalized}:"*) ;;
*)
new_path="${dir_normalized}${new_path:+:}${new_path}"
;;
esac
done
if [[ "$new_path" != "$PATH" ]]; then
export PATH="$new_path"
fi
}
remove-from-path() {
if [[ $# -eq 0 ]]; then
echo "usage: remove-from-path <path1> [path2 ...]" >&2
echo "example: remove-from-path /usr/local/bin /tmp/my-dir" >&2
return 1
fi
local original_ifs="$IFS"
local -a remove_paths=("$@")
local new_path=""
local path
local remove_path
local path_normalized
local remove_path_normalized
local -i keep_path=1 # 1=keep, 0=remove
IFS=':'
for path in $PATH; do
[[ -z "$path" ]] && continue
path_normalized="${path%/}" # remove / at tail
keep_path=1
for remove_path in "${remove_paths[@]}"; do
remove_path_normalized="${remove_path%/}"
if [[ "$path_normalized" == "$remove_path_normalized" ]]; then
keep_path=0
break
fi
done
if [[ $keep_path -eq 1 ]]; then
new_path="${new_path}${new_path:+:}${path}"
fi
done
IFS="$original_ifs"
export PATH="${new_path}"
}
show-path() {
echo "$PATH" | tr ':' '\n' | nl -w2 -s'. '
}
unhash-command-in-dirs() {
if [[ $# -eq 0 ]]; then
echo "usage: unhash-command-in-dir <dir1> [dir2 ...]" >&2
echo "example: unhash-command-in-dir ~/.local/bin/ ~/.volta/bin/" >&2
return 1
fi
local -a dirs=("$1")
local dir
local dir_normalized
local file_path
local filename
for dir in "${dirs[@]}"; do
[[ -z "$dir" || ! -d "$dir" ]] && continue
dir_normalized="${dir%/}"
for file_path in "$dir_normalized"/*; do
[[ ! -f "$file_path" || ! -x "$file_path" ]] && continue
filename="$(basename "$file_path")"
hash -d "$filename" 2>/dev/null
done
done
}

28
dot/.bashrc.d/mise.bash Normal file
View File

@@ -0,0 +1,28 @@
basedir=$(realpath -m $(dirname "${BASH_SOURCE[0]:-$0}"))
source "${basedir}/function.bash"
unset basedir
if [[ -x $(type -p mise) ]]; then
completion_cmd="mise completion --include-bash-completion-lib bash"
generate-bash-completion mise "$completion_cmd"
unset completion_cmd
mise-activate() {
eval "$(mise activate bash)"
}
mise-deactivate() {
mise deactivate
if [[ "$(type -p cd)" == "function" ]]; then
unset cd
fi
local all_mise=$(compgen -v | grep -i '_mise')
local mise
for mise in $all_mise; do
unset "$mise"
done
}
fi

View File

@@ -0,0 +1,10 @@
if [[ -x $(type -p pip_search) ]]; then
function _pip() {
if [[ "$1" == "search" ]]; then
pip_search "$2"
else
pip "$@"
fi
}
alias pip=_pip
fi

24
dot/.bashrc.d/pnpm.bash Executable file
View File

@@ -0,0 +1,24 @@
basedir=$(realpath -m $(dirname "${BASH_SOURCE[0]:-$0}"))
source "${basedir}/function.bash"
unset basedir
export PNPM_HOME="${HOME}/.local/share/pnpm"
add-to-path $PNPM_HOME
if [[ -x "$(type -p pnpm)" ]]; then
generate-bash-completion pnpm "pnpm completion bash"
fi
if [[ -x "$(type -p npm)" ]]; then
generate-bash-completion npm "npm completion"
fi
clean-pnpm-node() {
if [[ -d "$PNPM_HOME" ]]; then
rm -f "$[PNPM_HOME]/nodejs_current"
rm -f "${PNPM_HOME}/node"
rm -f "${PNPM_HOME}/npm"
rm -f "${PNPM_HOME}/npx"
fi
}

50
dot/.bashrc.d/proxy.bash Normal file
View File

@@ -0,0 +1,50 @@
HTTP_PROXY="http://192.168.1.13:20172"
SOCKS_PROXY="socks5://192.168.1.13:20170"
set-shell-proxy() {
export http_proxy="$HTTP_PROXY"
export https_proxy="$HTTP_PROXY"
}
unset-shell-proxy() {
unset http_proxy
unset https_proxy
}
set-git-proxy() {
prefix_cmd=""
flag="--global"
if [[ "$1" == "-s" ]]; then
prefix_cmd="sudo"
flag="--system"
elif [[ "$1" == "-l" ]]; then
flag="--local"
fi
$prefix_cmd git config $flag http.proxy $HTTP_PROXY
$prefix_cmd git config $flag http.sslVerify false
}
unset-git-proxy() {
prefix_cmd=""
flag="--global"
if [[ "$1" == "-s" ]]; then
prefix_cmd="sudo"
flag="--system"
elif [[ "$1" == "-l" ]]; then
flag="--local"
fi
$prefix_cmd git config $flag --unset http.proxy
$prefix_cmd git config $flag --unset http.sslVerify
}
set-npm-proxy() {
npm config set proxy $HTTP_PROXY
npm config set https-proxy $HTTP_PROXY
}
unset-npm-proxy() {
npm config delete proxy
npm config delete https-proxy
}

17
dot/.bashrc.d/rust.bash Normal file
View File

@@ -0,0 +1,17 @@
basedir=$(realpath -m $(dirname "${BASH_SOURCE[0]:-$0}"))
source "${basedir}/function.bash"
unset basedir
if [[ -d "${HOME}/.cargo/bin" ]]; then
add-to-path "${HOME}/.cargo/bin"
fi
if [[ -e "${HOME}/.cargo/env" ]]; then
. "${HOME}/.cargo/env"
fi
if [[ -x "$(type -p rustup)" ]]; then
generate-bash-completion rustup "rustup completions bash cargo"
generate-bash-completion cargo "rustup completions bash cargo"
fi

25
dot/.bashrc.d/volta.bash Normal file
View File

@@ -0,0 +1,25 @@
basedir=$(realpath -m $(dirname "${BASH_SOURCE[0]:-$0}"))
source "${basedir}/function.bash"
unset basedir
export VOLTA_HOME="${HOME}/.volta"
if [[ -x $(type -p volta) || -x "${VOLTA_HOME}/bin/volta" ]]; then
generate-bash-completion volta "volta completions bash"
volta-activate() {
add-to-path "${VOLTA_HOME}/bin"
# enable pnpm support
# export VOLTA_FEATURE_PNPM=1
}
volta-deactivate() {
local bin_dir="${VOLTA_HOME}/bin"
remove-from-path "$bin_dir"
unhash-command-in-dirs "$bin_dir"
}
fi

View File

@@ -1,3 +1,4 @@
[binhost]
priority = 9999
sync-uri = http://mirrors.ustc.edu.cn/gentoo/releases/amd64/binpackages/23.0/x86-64/
sync-uri = https://distfiles.gentoo.org/releases/amd64/binpackages/23.0/x86-64/
# sync-uri = http://mirrors.ustc.edu.cn/gentoo/releases/amd64/binpackages/23.0/x86-64/

View File

@@ -12,7 +12,7 @@ app-i18n/fcitx-rime ~amd64
app-i18n/librime ~amd64
# tree sitter
dev-libs/tree-sitter* ~amd64
# dev-libs/tree-sitter* ~amd64
# audroid studio
dev-util/android-studio::gentoo ~amd64
@@ -38,3 +38,8 @@ media-sound/bluez-alsa ~amd64
net-wireless/iwgtk ~amd64
sys-fs/jmtpfs ~amd64
app-office/wps-office ~amd64
# rustup
dev-util/rustup ~amd64

View File

@@ -1,3 +1,2 @@
app-office/wps-office::gentoo-zh
dev-lang/rust
net-proxy/shadowsocks-rust::gentoo-zh

View File

@@ -115,3 +115,6 @@ llvm-core/llvm xml
# freetype
media-libs/freetype harfbuzz
# watchman
dev-cpp/glog gflags

Binary file not shown.