feat(zsh): Finished reorganise zsh with a same entry point for all platforms

This commit is contained in:
js0ny 2024-11-30 01:29:47 +00:00
parent bd5ca49c3e
commit 2b21b63a13
22 changed files with 503 additions and 369 deletions

0
platforms/linux/.gitkeep Normal file
View file

View file

@ -1,33 +0,0 @@
# pip
alias pip=pip3
alias python=python3
python -m pip install --upgrade pip
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# npm
npm config set registry https://registry.npmmirror.com
# Homebrew
# 手动设置
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
# 注:自 brew 4.0 起,大部分 Homebrew 用户无需设置 homebrew/core 和 homebrew/cask 镜像,只需设置 HOMEBREW_API_DOMAIN 即可。
# 如果需要使用 Homebrew 的开发命令 (如 `brew cat <formula>`),则仍然需要设置 homebrew/core 和 homebrew/cask 镜像。
# 请按需执行如下两行命令:
brew tap --custom-remote --force-auto-update homebrew/core https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
brew tap --custom-remote --force-auto-update homebrew/cask https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
# 除 homebrew/core 和 homebrew/cask 仓库外的 tap 仓库仍然需要设置镜像
brew tap --custom-remote --force-auto-update homebrew/cask-fonts https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git
brew tap --custom-remote --force-auto-update homebrew/cask-versions https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-versions.git
brew tap --custom-remote --force-auto-update homebrew/command-not-found https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-command-not-found.git
brew tap --custom-remote --force-auto-update homebrew/services https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-services.git
brew update
# 或使用下面的几行命令自动设置
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
for tap in core cask{,-fonts,-versions} command-not-found services; do
brew tap --custom-remote --force-auto-update "homebrew/${tap}" "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-${tap}.git"
done
brew update

View file

@ -1,22 +1,15 @@
# $XDG_CONFIG_HOME/zsh/.zshrc
# ln -s $DOTFILES/mac/.zshrc $XDG_CONFIG_HOME/zsh/.zshrc
### Variables ###
# $DOTFILES/platforms/mac/zshrc
# Sourced by user's zshrc if is macOS 在用户的 zshrc 中被引用macOS 特定配置
# Entry point in $DOTFILES/tools/zsh/common.zshrc (入口点)
export DOTFILES="$HOME/.dotfiles"
# Homebrew Path
export PATH=/opt/homebrew/bin:/opt/homebrew/sbin:$PATH
for file in $DOTFILES/zsh/*.zsh; do
source $file
done
export ARCHFLAGS="-arch arm64"
### Navigation ###
# Absolute navigation
alias doku="cd ~/doku && ls"
alias docs="cd ~/Documents"
alias dt="cd ~/Desktop"
alias down="cd ~/Downloads"
alias one="cd ~/OneDrive"
alias gdrive="cd ~/Google\ Drive"
# macOS #
alias xclip="pbcopy"
alias clip="pbcopy"
alias paste="pbpaste"
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
@ -33,16 +26,3 @@ fi
unset __conda_setup
# <<< conda initialize <<<
# >>> juliaup initialize >>>
# !! Contents within this block are managed by juliaup !!
path=('$HOME/.juliaup/bin' $path)
export PATH
# <<< juliaup initialize <<<
# macOS #
alias xclip="pbcopy"
alias clip="pbcopy"

View file

@ -1,83 +0,0 @@
# $XDG_CONFIG_HOME/zsh/.zshrc
# ln -s $DOTFILES/wsl/.zshrc $XDG_CONFIG_HOME/zsh/.zshrc
### Variables ###
export IS_WSL=true
export DOTFILES="$HOME/.dotfiles"
for file in $DOTFILES/zsh/*.zsh; do
source $file
done
source $DOTFILES/wsl/winterop.zsh
source $ZDOTDIR/.zprivate.zsh
export ARCHFLAGS="-arch x86_64"
# Absolute navigation
alias src="cd ~/Source && ls"
alias dotfiles="cd $DOTFILES && ls"
### WSL Options ###
# WSL open
open() {
local target=$1
if command -v explorer.exe > /dev/null; then
explorer.exe "$target"
else
command open "$target"
fi
}
# WSL Neovide
gvi() {
local target=$1
if command -v neovide.exe > /dev/null; then
neovide.exe "$target"
else
if command -v neovide > /dev/null; then
neovide "$target"
else
echo "neovide is not installed"
fi
fi
}
### Misc ###
export PATH=/opt/bin:$PATH
# Conda #
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/js0ny/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/js0ny/miniconda3/etc/profile.d/conda.sh" ]; then
. "/home/js0ny/miniconda3/etc/profile.d/conda.sh"
else
export PATH="/home/js0ny/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
if [ -f /usr/share/doc/pkgfile/command-not-found.sh ]; then
source /usr/share/doc/pkgfile/command-not-found.sh
fi
# vcpkg
export VCPKG_ROOT=~/vcpkg
# Package Manager
alias pac="sudo pacman"
alias paci="sudo pacman -S"
alias pacr="sudo pacman -R"
alias pacu="sudo pacman -Syu"

View file

@ -1,3 +1,10 @@
# $DOTFILES/platforms/wsl/winterop.zsh
# Sourced by $DOTFILES/platforms/wsl/zshrc 在 $DOTFILES/platforms/wsl/zshrc 中被引用
# Defines the interop commands between WSL and Windows
export FILE_EXPLORER="dopus.exe" # Directory Opus
alias clip="clip.exe"
alias xclip="clip.exe"
alias paste='pwsh.exe -NoProfile -Command "Get-Clipboard"'
@ -13,3 +20,14 @@ alias diskpart="diskpart.exe"
alias winget="winget.exe"
alias pastew='pwsh.exe -NoProfile -Command "Get-Clipboard"'
alias ollama="ollama.exe"
# WSL open
open() {
local target=$1
if command -v "$FILE_EXPLORER" > /dev/null; then
"$FILE_EXPLORER" "$target"
else
command open "$target"
fi
}

31
platforms/wsl/zshrc Normal file
View file

@ -0,0 +1,31 @@
# $DOTFILES/platforms//zshrc
# Sourced by user's zshrc if is WSL 在用户的 zshrc 中被引用WSL 特定配置
# Entry point in $DOTFILES/tools/zsh/common.zshrc (入口点)
# TODO: Test on WSL
### Variables ###
export IS_WSL=true
export ARCHFLAGS="-arch x86_64"
source $DOTFILES/wsl/winterop.zsh
### Misc ###
export PATH=/opt/bin:$PATH
# Conda #
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('$HOME/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "$HOME/miniconda3/etc/profile.d/conda.sh" ]; then
. "$HOME/miniconda3/etc/profile.d/conda.sh"
else
export PATH="$HOME/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<