mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 00:33:00 +00:00
style: format shell scripts
This commit is contained in:
parent
8c5babe80a
commit
76b5fd4118
18 changed files with 231 additions and 242 deletions
|
|
@ -4,10 +4,9 @@
|
|||
# Sourced by user's zshrc if is Linux 在用户的 zshrc 中被引用
|
||||
# Entry point in $DOTFILES/tools/zsh/common.zshrc (入口点)
|
||||
|
||||
|
||||
if [ -n "$WAYLAND_DISPLAY" ]; then
|
||||
alias clip="wl-copy"
|
||||
alias paste="wl-paste"
|
||||
alias clip="wl-copy"
|
||||
alias paste="wl-paste"
|
||||
elif [ -n "$DISPLAY" ]; then
|
||||
alias clip="xclip"
|
||||
alias clip="xclip"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
# chmod +x ~/.config/sketchybar/plugins/aerospace.sh
|
||||
|
||||
if [ "$1" = "$FOCUSED_WORKSPACE" ]; then
|
||||
sketchybar --set $NAME background.drawing=on
|
||||
sketchybar --set $NAME background.drawing=on
|
||||
else
|
||||
sketchybar --set $NAME background.drawing=off
|
||||
sketchybar --set $NAME background.drawing=off
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -8,15 +8,19 @@ if [ "$PERCENTAGE" = "" ]; then
|
|||
fi
|
||||
|
||||
case "${PERCENTAGE}" in
|
||||
9[0-9]|100) ICON=""
|
||||
;;
|
||||
[6-8][0-9]) ICON=""
|
||||
;;
|
||||
[3-5][0-9]) ICON=""
|
||||
;;
|
||||
[1-2][0-9]) ICON=""
|
||||
;;
|
||||
*) ICON=""
|
||||
9[0-9] | 100)
|
||||
ICON=""
|
||||
;;
|
||||
[6-8][0-9])
|
||||
ICON=""
|
||||
;;
|
||||
[3-5][0-9])
|
||||
ICON=""
|
||||
;;
|
||||
[1-2][0-9])
|
||||
ICON=""
|
||||
;;
|
||||
*) ICON="" ;;
|
||||
esac
|
||||
|
||||
if [[ "$CHARGING" != "" ]]; then
|
||||
|
|
|
|||
|
|
@ -5,4 +5,3 @@
|
|||
# https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting
|
||||
|
||||
sketchybar --set "$NAME" label="$(date '+%d日周%u %H:%M')"
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
music_info=$(curlie GET http://localhost:10767/api/v1/playback/now-playing | jq -r '"\(.info.name) - \(.info.artistName)"')
|
||||
|
||||
|
||||
ICON=""
|
||||
|
||||
sketchybar --set $NAME label="$music_info" icon="$ICON"
|
||||
|
|
|
|||
|
|
@ -7,13 +7,16 @@ if [ "$SENDER" = "volume_change" ]; then
|
|||
VOLUME="$INFO"
|
||||
|
||||
case "$VOLUME" in
|
||||
[6-9][0-9]|100) ICON=""
|
||||
;;
|
||||
[3-5][0-9]) ICON=""
|
||||
;;
|
||||
[1-9]|[1-2][0-9]) ICON=""
|
||||
;;
|
||||
*) ICON=""
|
||||
[6-9][0-9] | 100)
|
||||
ICON=""
|
||||
;;
|
||||
[3-5][0-9])
|
||||
ICON=""
|
||||
;;
|
||||
[1-9] | [1-2][0-9])
|
||||
ICON=""
|
||||
;;
|
||||
*) ICON="" ;;
|
||||
esac
|
||||
|
||||
sketchybar --set "$NAME" icon="$ICON" label="$VOLUME%"
|
||||
|
|
|
|||
|
|
@ -42,9 +42,8 @@ sketchybar --default "${default[@]}"
|
|||
# to indicate active and available mission control spaces.
|
||||
|
||||
SPACE_ICONS=("" "" "" "" "" "" "7" "8" "9" "10")
|
||||
for i in "${!SPACE_ICONS[@]}"
|
||||
do
|
||||
sid="$(($i+1))"
|
||||
for i in "${!SPACE_ICONS[@]}"; do
|
||||
sid="$(($i + 1))"
|
||||
space=(
|
||||
space="$sid"
|
||||
icon="${SPACE_ICONS[i]}"
|
||||
|
|
@ -65,10 +64,10 @@ done
|
|||
# only the properties deviating from the current defaults need to be set
|
||||
|
||||
sketchybar --add item chevron left \
|
||||
--set chevron icon= label.drawing=off \
|
||||
--add item front_app left \
|
||||
--set front_app icon.drawing=off script="$PLUGIN_DIR/front_app.sh" \
|
||||
--subscribe front_app front_app_switched
|
||||
--set chevron icon= label.drawing=off \
|
||||
--add item front_app left \
|
||||
--set front_app icon.drawing=off script="$PLUGIN_DIR/front_app.sh" \
|
||||
--subscribe front_app front_app_switched
|
||||
|
||||
##### Adding Right Items #####
|
||||
# In the same way as the left items we can add items to the right side.
|
||||
|
|
@ -82,37 +81,36 @@ sketchybar --add item chevron left \
|
|||
# https://felixkratz.github.io/SketchyBar/config/events
|
||||
|
||||
sketchybar --add item clock center \
|
||||
--set clock update_freq=10 icon= script="$PLUGIN_DIR/clock.sh" \
|
||||
--add item volume right \
|
||||
--set volume script="$PLUGIN_DIR/volume.sh" \
|
||||
--subscribe volume volume_change \
|
||||
--add item battery right \
|
||||
--set battery update_freq=120 script="$PLUGIN_DIR/battery.sh" \
|
||||
--subscribe battery system_woke power_source_change \
|
||||
--add item apple_music right
|
||||
--set clock update_freq=10 icon= script="$PLUGIN_DIR/clock.sh" \
|
||||
--add item volume right \
|
||||
--set volume script="$PLUGIN_DIR/volume.sh" \
|
||||
--subscribe volume volume_change \
|
||||
--add item battery right \
|
||||
--set battery update_freq=120 script="$PLUGIN_DIR/battery.sh" \
|
||||
--subscribe battery system_woke power_source_change \
|
||||
--add item apple_music right
|
||||
|
||||
sketchybar --add item music right
|
||||
sketchybar --set music \
|
||||
script="$PLUGIN_DIR/music.sh" \
|
||||
update_freq=5 \
|
||||
label.color=0xffd7ba7d \
|
||||
background.corner_radius=5
|
||||
script="$PLUGIN_DIR/music.sh" \
|
||||
update_freq=5 \
|
||||
label.color=0xffd7ba7d \
|
||||
background.corner_radius=5
|
||||
|
||||
##### Force all scripts to run the first time (never do this in a script) #####
|
||||
sketchybar --update
|
||||
|
||||
|
||||
sketchybar --add event aerospace_workspace_change
|
||||
|
||||
for sid in $(aerospace list-workspaces --all); do
|
||||
sketchybar --add item space.$sid left \
|
||||
--subscribe space.$sid aerospace_workspace_change \
|
||||
--set space.$sid \
|
||||
background.color=0x44ffffff \
|
||||
background.corner_radius=5 \
|
||||
background.height=20 \
|
||||
background.drawing=off \
|
||||
label="$sid" \
|
||||
click_script="aerospace workspace $sid" \
|
||||
script="$CONFIG_DIR/plugins/aerospace.sh $sid"
|
||||
sketchybar --add item space.$sid left \
|
||||
--subscribe space.$sid aerospace_workspace_change \
|
||||
--set space.$sid \
|
||||
background.color=0x44ffffff \
|
||||
background.corner_radius=5 \
|
||||
background.height=20 \
|
||||
background.drawing=off \
|
||||
label="$sid" \
|
||||
click_script="aerospace workspace $sid" \
|
||||
script="$CONFIG_DIR/plugins/aerospace.sh $sid"
|
||||
done
|
||||
|
|
|
|||
|
|
@ -11,15 +11,15 @@ alias paste="pbpaste"
|
|||
|
||||
# >>> conda initialize >>>
|
||||
# !! Contents within this block are managed by 'conda init' !!
|
||||
__conda_setup="$('/opt/homebrew/Caskroom/miniconda/base/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
|
||||
__conda_setup="$('/opt/homebrew/Caskroom/miniconda/base/bin/conda' 'shell.zsh' 'hook' 2>/dev/null)"
|
||||
if [ $? -eq 0 ]; then
|
||||
eval "$__conda_setup"
|
||||
eval "$__conda_setup"
|
||||
else
|
||||
if [ -f "/opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh" ]; then
|
||||
. "/opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh"
|
||||
else
|
||||
export PATH="/opt/homebrew/Caskroom/miniconda/base/bin:$PATH"
|
||||
fi
|
||||
if [ -f "/opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh" ]; then
|
||||
. "/opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh"
|
||||
else
|
||||
export PATH="/opt/homebrew/Caskroom/miniconda/base/bin:$PATH"
|
||||
fi
|
||||
fi
|
||||
unset __conda_setup
|
||||
# <<< conda initialize <<<
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ export IS_WSL=true
|
|||
export ARCHFLAGS="-arch x86_64"
|
||||
source $DOTFILES/platforms/wsl/winterop.zsh
|
||||
|
||||
|
||||
### Misc ###
|
||||
|
||||
export PATH=/opt/bin:$PATH
|
||||
|
|
@ -18,15 +17,15 @@ export PATH=/opt/bin:$PATH
|
|||
|
||||
# >>> conda initialize >>>
|
||||
# !! Contents within this block are managed by 'conda init' !!
|
||||
__conda_setup="$('$HOME/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
|
||||
__conda_setup="$('$HOME/miniconda3/bin/conda' 'shell.zsh' 'hook' 2>/dev/null)"
|
||||
if [ $? -eq 0 ]; then
|
||||
eval "$__conda_setup"
|
||||
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
|
||||
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 <<<
|
||||
|
|
|
|||
|
|
@ -42,5 +42,5 @@ fi
|
|||
|
||||
# macOS - Rime
|
||||
if [ $(uname) = "Darwin" ]; then
|
||||
bash ~/plum/rime-install
|
||||
bash ~/plum/rime-install
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -15,5 +15,5 @@ export XDG_RUNTIME_DIR="/run/user/$(id -u)"
|
|||
|
||||
# Source user's XDG-compliant Bash configs
|
||||
if [ -f "$XDG_CONFIG_HOME/bash/profile" ]; then
|
||||
. "$XDG_CONFIG_HOME/bash/profile"
|
||||
. "$XDG_CONFIG_HOME/bash/profile"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ alias sn="sudo nvim -u ~/.config/nvim/init.lua"
|
|||
|
||||
# Dev #
|
||||
alias gpp='g++ -std=c++2b' # Set the default C++ standard to C++20
|
||||
alias gcc='gcc -std=c99' # Set the default C standard to C99
|
||||
alias gcc='gcc -std=c99' # Set the default C standard to C99
|
||||
alias cl='clang -std=c99'
|
||||
alias clpp='clang++ -std=c++2b'
|
||||
alias python=python3 # Set the default Python version to Python 3
|
||||
|
|
@ -27,77 +27,73 @@ alias ipy=ipython
|
|||
|
||||
alias g=lazygit
|
||||
|
||||
|
||||
# lsd - modern ls
|
||||
if command -v lsd >/dev/null 2>&1; then
|
||||
alias ls='lsd'
|
||||
alias l='lsd -lah'
|
||||
alias ll='lsd -l'
|
||||
alias la='lsd -A'
|
||||
alias l.='lsd -d .*'
|
||||
alias tree='lsd --tree -A'
|
||||
alias ls='lsd'
|
||||
alias l='lsd -lah'
|
||||
alias ll='lsd -l'
|
||||
alias la='lsd -A'
|
||||
alias l.='lsd -d .*'
|
||||
alias tree='lsd --tree -A'
|
||||
else
|
||||
alias l='ls -lah'
|
||||
alias ll='ls -l'
|
||||
alias l='ls -lah'
|
||||
alias ll='ls -l'
|
||||
fi
|
||||
|
||||
|
||||
# Functions #
|
||||
mkcd() {
|
||||
mkdir -p $1 && cd $1
|
||||
}
|
||||
cdls(){
|
||||
cd $1 && ls
|
||||
cdls() {
|
||||
cd $1 && ls
|
||||
}
|
||||
tc(){
|
||||
touch $1 && code $1
|
||||
tc() {
|
||||
touch $1 && code $1
|
||||
}
|
||||
tv(){
|
||||
touch $1 && nvim $1
|
||||
tv() {
|
||||
touch $1 && nvim $1
|
||||
}
|
||||
mt(){
|
||||
mkdir -p $(dirname $1) && touch $1
|
||||
mt() {
|
||||
mkdir -p $(dirname $1) && touch $1
|
||||
}
|
||||
mtv(){
|
||||
mkdir -p $(dirname $1) && touch $1 && nvim $1
|
||||
mtv() {
|
||||
mkdir -p $(dirname $1) && touch $1 && nvim $1
|
||||
}
|
||||
|
||||
|
||||
alias update="source $DOTFILES/scripts/update.zsh"
|
||||
|
||||
if command -v pacman >/dev/null 2>&1; then
|
||||
alias pac="sudo pacman"
|
||||
alias paci="sudo pacman -S"
|
||||
alias pacr="sudo pacman -R"
|
||||
alias pacu="sudo pacman -Syu"
|
||||
alias pacl="pacman -Q"
|
||||
if command -v paru >/dev/null 2>&1; then
|
||||
alias pacs="paru -Ss"
|
||||
elif command -v yay >/dev/null 2>&1; then
|
||||
alias pacs="yay -Ss"
|
||||
else
|
||||
alias pacs="pacman -Ss"
|
||||
fi
|
||||
alias pac="sudo pacman"
|
||||
alias paci="sudo pacman -S"
|
||||
alias pacr="sudo pacman -R"
|
||||
alias pacu="sudo pacman -Syu"
|
||||
alias pacl="pacman -Q"
|
||||
if command -v paru >/dev/null 2>&1; then
|
||||
alias pacs="paru -Ss"
|
||||
elif command -v yay >/dev/null 2>&1; then
|
||||
alias pacs="yay -Ss"
|
||||
else
|
||||
alias pacs="pacman -Ss"
|
||||
fi
|
||||
fi
|
||||
|
||||
if command -v apt >/dev/null 2>&1; then
|
||||
alias apt="sudo apt"
|
||||
alias apti="sudo apt install"
|
||||
alias aptr="sudo apt remove"
|
||||
alias aptu="sudo apt update && sudo apt upgrade"
|
||||
alias apts="apt search"
|
||||
alias aptl="apt list --installed"
|
||||
alias apt="sudo apt"
|
||||
alias apti="sudo apt install"
|
||||
alias aptr="sudo apt remove"
|
||||
alias aptu="sudo apt update && sudo apt upgrade"
|
||||
alias apts="apt search"
|
||||
alias aptl="apt list --installed"
|
||||
fi
|
||||
|
||||
if command -v brew >/dev/null 2>&1; then
|
||||
alias brewi="brew install"
|
||||
alias brewr="brew uninstall"
|
||||
alias brewu="brew update && brew upgrade"
|
||||
alias brews="brew search"
|
||||
alias brewl="brew list"
|
||||
alias brewi="brew install"
|
||||
alias brewr="brew uninstall"
|
||||
alias brewu="brew update && brew upgrade"
|
||||
alias brews="brew search"
|
||||
alias brewl="brew list"
|
||||
fi
|
||||
|
||||
|
||||
# `-s` suffix alias
|
||||
# % readme.md -> glow readme.md
|
||||
alias -s {md,markdown}=glow
|
||||
|
|
@ -107,11 +103,11 @@ alias -s {cs,csx,fs,fsx,razor}=code
|
|||
|
||||
# TODO: Does not work
|
||||
if [ "$TERM" = "xterm-ghostty" ] || [ "$TERM" = "xterm-kitty" ]; then
|
||||
alias icat="kitten icat"
|
||||
alias icat="kitten icat"
|
||||
elif [ "$TERM_PROGRAM" = "WezTerm" ]; then
|
||||
if [ -n "$WSL_DISTRO_NAME" ]; then
|
||||
alias icat="wezterm.exe imgcat"
|
||||
else
|
||||
alias icat="wezterm imgcat"
|
||||
fi
|
||||
if [ -n "$WSL_DISTRO_NAME" ]; then
|
||||
alias icat="wezterm.exe imgcat"
|
||||
else
|
||||
alias icat="wezterm imgcat"
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -12,32 +12,30 @@ SAVEHIST=10000
|
|||
export LANG=zh_CN.UTF-8
|
||||
export LC_ALL=zh_CN.UTF-8
|
||||
|
||||
|
||||
# Manually manage plugins 手动管理插件
|
||||
# Load zsh-syntax-highlighting before zsh-history-substring-search
|
||||
# Reference: https://github.com/zsh-users/zsh-history-substring-search?tab=readme-ov-file#usage
|
||||
plugins=(
|
||||
"zsh-autosuggestions"
|
||||
"zsh-syntax-highlighting"
|
||||
"zsh-history-substring-search"
|
||||
"zsh-completions"
|
||||
"zsh-autosuggestions"
|
||||
"zsh-syntax-highlighting"
|
||||
"zsh-history-substring-search"
|
||||
"zsh-completions"
|
||||
)
|
||||
|
||||
plugin_dir="$ZDOTDIR/plugins"
|
||||
|
||||
for plugin in "${plugins[@]}"; do
|
||||
plugin_path="$plugin_dir/$plugin/$plugin.zsh"
|
||||
plugin_path_alt="$plugin_dir/$plugin/$plugin.plugin.zsh"
|
||||
if [[ -f $plugin_path ]]; then
|
||||
source "$plugin_path"
|
||||
elif [[ -f $plugin_path_alt ]]; then
|
||||
source "$plugin_path_alt"
|
||||
else
|
||||
echo "Warning: Plugin not found: $plugin_path"
|
||||
fi
|
||||
plugin_path="$plugin_dir/$plugin/$plugin.zsh"
|
||||
plugin_path_alt="$plugin_dir/$plugin/$plugin.plugin.zsh"
|
||||
if [[ -f $plugin_path ]]; then
|
||||
source "$plugin_path"
|
||||
elif [[ -f $plugin_path_alt ]]; then
|
||||
source "$plugin_path_alt"
|
||||
else
|
||||
echo "Warning: Plugin not found: $plugin_path"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# https://unix.stackexchange.com/questions/33994/
|
||||
# Use `set -k` to mark leading `#` as a comment character
|
||||
set -k
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
# Author: js0ny
|
||||
# Sourced by user's zshrc 在用户的 zshrc 中被引用
|
||||
|
||||
|
||||
# read key: `fish_key_reader`
|
||||
# get current bindings: `bindkey`
|
||||
|
||||
|
|
|
|||
|
|
@ -3,51 +3,48 @@
|
|||
# Author: js0ny
|
||||
# Sourced by user's zshrc 在用户的 zshrc 中被引用
|
||||
|
||||
|
||||
|
||||
# Absolute navigation #
|
||||
alias dotfiles="cd $DOTFILES && ls"
|
||||
if [ "$IS_WSL" = true ]; then # IS_WSL is defined in $DOTFILES/platforms/wsl/zshrc
|
||||
winuser=$(whoami.exe | cut -d'\' -f2 | tr -d '\r')
|
||||
alias dt="cd /mnt/c/Users/$winuser/Desktop && ls"
|
||||
alias doku="cd /mnt/c/Users/$winuser/Documents && ls"
|
||||
alias down="cd /mnt/c/Users/$winuser/Downloads && ls"
|
||||
alias src="cd /mnt/d/Source"
|
||||
alias one="cd /mnt/c/Users/$winuser/OneDrive"
|
||||
alias gdrive="cd /mnt/g"
|
||||
winuser=$(whoami.exe | cut -d'\' -f2 | tr -d '\r')
|
||||
alias dt="cd /mnt/c/Users/$winuser/Desktop && ls"
|
||||
alias doku="cd /mnt/c/Users/$winuser/Documents && ls"
|
||||
alias down="cd /mnt/c/Users/$winuser/Downloads && ls"
|
||||
alias src="cd /mnt/d/Source"
|
||||
alias one="cd /mnt/c/Users/$winuser/OneDrive"
|
||||
alias gdrive="cd /mnt/g"
|
||||
else
|
||||
alias dt="cd $HOME/Desktop && ls"
|
||||
alias doku="cd $HOME/Documents && ls"
|
||||
alias down="cd $HOME/Downloads && ls"
|
||||
alias src="cd $HOME/Documents/Source"
|
||||
alias dt="cd $HOME/Desktop && ls"
|
||||
alias doku="cd $HOME/Documents && ls"
|
||||
alias down="cd $HOME/Downloads && ls"
|
||||
alias src="cd $HOME/Documents/Source"
|
||||
fi
|
||||
|
||||
# macOS specific, no OneDrive & Google Drive on Linux
|
||||
if [ "$(uname)" = "Darwin" ]; then
|
||||
alias one="cd $HOME/OneDrive"
|
||||
alias gdrive="cd $HOME/Google Drive"
|
||||
alias one="cd $HOME/OneDrive"
|
||||
alias gdrive="cd $HOME/Google Drive"
|
||||
fi
|
||||
|
||||
|
||||
if command -v zoxide >/dev/null 2>&1; then
|
||||
eval "$(zoxide init zsh)"
|
||||
# Relative navigation #
|
||||
alias ..="z .."
|
||||
alias ...="z ../.."
|
||||
alias ....="z ../../.."
|
||||
alias .....="z ../../../.."
|
||||
alias ......="z ../../../../.."
|
||||
# Use `-` to jump to the previous directory
|
||||
# Oh-My-Zsh defines a similar one
|
||||
alias - "z -"
|
||||
zls(){
|
||||
cd $1 && ls
|
||||
}
|
||||
eval "$(zoxide init zsh)"
|
||||
# Relative navigation #
|
||||
alias ..="z .."
|
||||
alias ...="z ../.."
|
||||
alias ....="z ../../.."
|
||||
alias .....="z ../../../.."
|
||||
alias ......="z ../../../../.."
|
||||
# Use `-` to jump to the previous directory
|
||||
# Oh-My-Zsh defines a similar one
|
||||
alias - "z -"
|
||||
zls() {
|
||||
cd $1 && ls
|
||||
}
|
||||
else
|
||||
alias ..="cd .."
|
||||
alias ...="cd ../.."
|
||||
alias ....="cd ../../.."
|
||||
alias .....="cd ../../../.."
|
||||
alias ......="cd ../../../../.."
|
||||
alias - "cd -"
|
||||
alias ..="cd .."
|
||||
alias ...="cd ../.."
|
||||
alias ....="cd ../../.."
|
||||
alias .....="cd ../../../.."
|
||||
alias ......="cd ../../../../.."
|
||||
alias - "cd -"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -3,6 +3,4 @@
|
|||
# Author: js0ny
|
||||
# Sourced by user's zshrc 在用户的 zshrc 中被引用
|
||||
|
||||
|
||||
eval "$(starship init zsh)"
|
||||
|
||||
|
|
|
|||
126
tools/zsh/zshenv
126
tools/zsh/zshenv
|
|
@ -37,9 +37,9 @@ export VISUAL="nvim"
|
|||
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
|
||||
|
||||
if [ -d "/opt/homebrew/bin" ]; then # macOS
|
||||
export PATH="/opt/homebrew/bin:$PATH"
|
||||
export PATH="/opt/homebrew/bin:$PATH"
|
||||
elif [ -d "/home/linuxbrew/.linuxbrew/bin" ]; then # Linux
|
||||
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
|
||||
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
|
||||
fi
|
||||
|
||||
# macOS Specific
|
||||
|
|
@ -50,115 +50,115 @@ fi
|
|||
|
||||
# Linux Specific
|
||||
if [ "$(uname)" = "Linux" ]; then
|
||||
# CUDA
|
||||
export CUDA_CACHE_PATH="$XDG_CACHE_HOME"/nv
|
||||
# CUDA
|
||||
export CUDA_CACHE_PATH="$XDG_CACHE_HOME"/nv
|
||||
fi
|
||||
|
||||
# Azure CLI
|
||||
if command -v az > /dev/null; then
|
||||
export AZURE_CONFIG_DIR="$XDG_DATA_HOME"/azure
|
||||
if command -v az >/dev/null; then
|
||||
export AZURE_CONFIG_DIR="$XDG_DATA_HOME"/azure
|
||||
fi
|
||||
# Bun JS
|
||||
# mv ~/.bun $XDG_DATA_HOME/bun
|
||||
# ln -sf $XDG_DATA_HOME/bun/bin/bun ~/.local/bin/bun
|
||||
if command -v bun > /dev/null; then
|
||||
export BUN_INSTALL="$XDG_DATA_HOME"/bun
|
||||
export PATH="$BUN_INSTALL/bin:$PATH"
|
||||
[ -s "$BUN_INSTALL/_bun" ] && source "$BUN_INSTALL/_bun"
|
||||
if command -v bun >/dev/null; then
|
||||
export BUN_INSTALL="$XDG_DATA_HOME"/bun
|
||||
export PATH="$BUN_INSTALL/bin:$PATH"
|
||||
[ -s "$BUN_INSTALL/_bun" ] && source "$BUN_INSTALL/_bun"
|
||||
fi
|
||||
# Cargo
|
||||
if command -v cargo > /dev/null; then
|
||||
export CARGO_HOME="$XDG_DATA_HOME"/cargo
|
||||
export PATH="$CARGO_HOME/bin:$PATH"
|
||||
if command -v cargo >/dev/null; then
|
||||
export CARGO_HOME="$XDG_DATA_HOME"/cargo
|
||||
export PATH="$CARGO_HOME/bin:$PATH"
|
||||
fi
|
||||
# CGDB
|
||||
if command -v cgdb > /dev/null; then
|
||||
export CGDB_DIR="$XDG_CONFIG_HOME"/cgdb
|
||||
if command -v cgdb >/dev/null; then
|
||||
export CGDB_DIR="$XDG_CONFIG_HOME"/cgdb
|
||||
fi
|
||||
# .NET
|
||||
if command -v dotnet > /dev/null; then
|
||||
export DOTNET_CLI_HOME="$XDG_DATA_HOME"/dotnet
|
||||
export PATH="$DOTNET_CLI_HOME/.dotnet/tools:$PATH"
|
||||
if command -v dotnet >/dev/null; then
|
||||
export DOTNET_CLI_HOME="$XDG_DATA_HOME"/dotnet
|
||||
export PATH="$DOTNET_CLI_HOME/.dotnet/tools:$PATH"
|
||||
fi
|
||||
# Docker
|
||||
if command -v docker > /dev/null; then
|
||||
export DOCKER_CONFIG="$XDG_CONFIG_HOME"/docker
|
||||
if command -v docker >/dev/null; then
|
||||
export DOCKER_CONFIG="$XDG_CONFIG_HOME"/docker
|
||||
fi
|
||||
# GnuPG
|
||||
if command -v gpg > /dev/null; then
|
||||
export GNUPGHOME="$XDG_DATA_HOME"/gnupg
|
||||
if command -v gpg >/dev/null; then
|
||||
export GNUPGHOME="$XDG_DATA_HOME"/gnupg
|
||||
fi
|
||||
# Go
|
||||
if command -v go > /dev/null; then
|
||||
export GOPATH="$XDG_DATA_HOME"/go
|
||||
export PATH="$GOPATH/bin:$PATH"
|
||||
if command -v go >/dev/null; then
|
||||
export GOPATH="$XDG_DATA_HOME"/go
|
||||
export PATH="$GOPATH/bin:$PATH"
|
||||
fi
|
||||
# Julia
|
||||
if command -v julia > /dev/null; then
|
||||
export JULIA_DEPOT_PATH="$XDG_DATA_HOME/julia:$JULIA_DEPOT_PATH"
|
||||
if command -v julia >/dev/null; then
|
||||
export JULIA_DEPOT_PATH="$XDG_DATA_HOME/julia:$JULIA_DEPOT_PATH"
|
||||
fi
|
||||
# Node.js
|
||||
if command -v node > /dev/null; then
|
||||
export NODE_REPL_HISTORY="$XDG_STATE_HOME"/node/repl_history
|
||||
export TS_NODE_REPL_HISTORY="$XDG_STATE_HOME"/node/ts_node_repl_history
|
||||
export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME"/npm/npmrc
|
||||
export NPM_CONFIG_INIT_MODULE="$XDG_CONFIG_HOME"/npm/config/npm-init.js
|
||||
export NPM_CONFIG_CACHE="$XDG_CACHE_HOME"/npm
|
||||
export NPM_CONFIG_TMP="$XDG_RUNTIME_DIR"/npm
|
||||
if command -v node >/dev/null; then
|
||||
export NODE_REPL_HISTORY="$XDG_STATE_HOME"/node/repl_history
|
||||
export TS_NODE_REPL_HISTORY="$XDG_STATE_HOME"/node/ts_node_repl_history
|
||||
export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME"/npm/npmrc
|
||||
export NPM_CONFIG_INIT_MODULE="$XDG_CONFIG_HOME"/npm/config/npm-init.js
|
||||
export NPM_CONFIG_CACHE="$XDG_CACHE_HOME"/npm
|
||||
export NPM_CONFIG_TMP="$XDG_RUNTIME_DIR"/npm
|
||||
fi
|
||||
# Parallel
|
||||
if command -v parallel > /dev/null; then
|
||||
export PARALLEL_HOME="$XDG_CONFIG_HOME"/parallel
|
||||
if command -v parallel >/dev/null; then
|
||||
export PARALLEL_HOME="$XDG_CONFIG_HOME"/parallel
|
||||
fi
|
||||
# Python
|
||||
# Works only with Python 3.13.0a3 and later
|
||||
if command -v python3 > /dev/null; then
|
||||
export PYTHON_HISTORY="$XDG_DATA_HOME"/python/history
|
||||
if command -v python3 >/dev/null; then
|
||||
export PYTHON_HISTORY="$XDG_DATA_HOME"/python/history
|
||||
fi
|
||||
# GNU Screen
|
||||
if command -v screen > /dev/null; then
|
||||
export SCREENRC="$XDG_CONFIG_HOME"/screen/screenrc
|
||||
export SCREENDIR="${XDG_RUNTIME_DIR}/screen"
|
||||
if command -v screen >/dev/null; then
|
||||
export SCREENRC="$XDG_CONFIG_HOME"/screen/screenrc
|
||||
export SCREENDIR="${XDG_RUNTIME_DIR}/screen"
|
||||
fi
|
||||
# Ruby Gem
|
||||
# Ruby Gem
|
||||
if command -v gem > /dev/null; then
|
||||
setopt nullglob
|
||||
for dir in "$HOME/.local/share/gem/ruby/"*/bin; do
|
||||
if [ -d "$dir" ]; then
|
||||
export PATH="$dir:$PATH"
|
||||
fi
|
||||
done
|
||||
unsetopt nullglob
|
||||
if command -v gem >/dev/null; then
|
||||
setopt nullglob
|
||||
for dir in "$HOME/.local/share/gem/ruby/"*/bin; do
|
||||
if [ -d "$dir" ]; then
|
||||
export PATH="$dir:$PATH"
|
||||
fi
|
||||
done
|
||||
unsetopt nullglob
|
||||
fi
|
||||
# Spacemacs
|
||||
if command -v emacs > /dev/null; then
|
||||
export SPACEMACSDIR="$XDG_CONFIG_HOME"/spacemacs
|
||||
if command -v emacs >/dev/null; then
|
||||
export SPACEMACSDIR="$XDG_CONFIG_HOME"/spacemacs
|
||||
fi
|
||||
# tldr
|
||||
# Works only with C client (did not verify)
|
||||
if command -v tldr > /dev/null; then
|
||||
export TLDR_CACHE_DIR="$XDG_CACHE_HOME"/tldr
|
||||
if command -v tldr >/dev/null; then
|
||||
export TLDR_CACHE_DIR="$XDG_CACHE_HOME"/tldr
|
||||
fi
|
||||
# W3M
|
||||
if command -v w3m > /dev/null; then
|
||||
export W3M_DIR="$XDG_DATA_HOME"/w3m
|
||||
if command -v w3m >/dev/null; then
|
||||
export W3M_DIR="$XDG_DATA_HOME"/w3m
|
||||
fi
|
||||
# Wakatime
|
||||
if command -v wakatime > /dev/null; then
|
||||
export WAKATIME_HOME="$XDG_CONFIG_HOME/wakatime"
|
||||
if command -v wakatime >/dev/null; then
|
||||
export WAKATIME_HOME="$XDG_CONFIG_HOME/wakatime"
|
||||
fi
|
||||
# Wget
|
||||
if command -v wget > /dev/null; then
|
||||
alias wget='wget --hsts-file="$XDG_CACHE_HOME/wget-hsts"'
|
||||
if command -v wget >/dev/null; then
|
||||
alias wget='wget --hsts-file="$XDG_CACHE_HOME/wget-hsts"'
|
||||
fi
|
||||
# z
|
||||
if command -v z > /dev/null; then
|
||||
export _Z_DATA="$XDG_DATA_HOME/z"
|
||||
if command -v z >/dev/null; then
|
||||
export _Z_DATA="$XDG_DATA_HOME/z"
|
||||
fi
|
||||
# zsh .zcompdump
|
||||
# compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION"
|
||||
# Vcpkg
|
||||
if command -v vcpkg > /dev/null; then
|
||||
export VCPKG_ROOT="$XDG_DATA_HOME"/vcpkg
|
||||
if command -v vcpkg >/dev/null; then
|
||||
export VCPKG_ROOT="$XDG_DATA_HOME"/vcpkg
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ case "$(uname)" in
|
|||
# macOS-specific configuration
|
||||
source "$DOTFILES/platforms/mac/zshrc"
|
||||
;;
|
||||
# CYGWIN*|MINGW*|MSYS*)
|
||||
# source "$DOTFILES/platform/wsl.zsh"
|
||||
# ;;
|
||||
# CYGWIN*|MINGW*|MSYS*)
|
||||
# source "$DOTFILES/platform/wsl.zsh"
|
||||
# ;;
|
||||
esac
|
||||
|
||||
for file in $DOTFILES/tools/zsh/mod/*.zsh; do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue