mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 08:43:00 +00:00
chezmoi: zsh, starship
This commit is contained in:
parent
0051a163c3
commit
2cbf244d7b
17 changed files with 0 additions and 1102 deletions
115
dot_config/zsh/mod/alias.zsh
Normal file
115
dot_config/zsh/mod/alias.zsh
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
# $DOTFILES/tools/zsh/mod/alias.zsh
|
||||
# Date: 2024-11-30
|
||||
# Author: js0ny
|
||||
# Sourced by user's zshrc 在用户的 zshrc 中被引用
|
||||
|
||||
# PowerShell Equivalent, for cross-platform compatibility
|
||||
alias ni=touch
|
||||
alias cls=clear
|
||||
alias ii=open
|
||||
|
||||
# Editors #
|
||||
alias v=nvim
|
||||
alias c=code
|
||||
# Use neovide as gVim
|
||||
alias gvi="neovide"
|
||||
alias svi="sudo vim -u ~/.dotfiles/common/vim.noxdg.vimrc" # Prevent conflicts with svelte-cli
|
||||
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 cl='clang -std=c99'
|
||||
alias clpp='clang++ -std=c++2b'
|
||||
alias python=python3 # Set the default Python version to Python 3
|
||||
alias py=python
|
||||
alias ipy=ipython
|
||||
|
||||
alias g=lazygit
|
||||
|
||||
alias doomrc="emacsclient -t ~/.config/doom/"
|
||||
|
||||
# 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'
|
||||
else
|
||||
alias l='ls -lah'
|
||||
alias ll='ls -l'
|
||||
fi
|
||||
|
||||
# Functions #
|
||||
mkcd() {
|
||||
mkdir -p $1 && cd $1
|
||||
}
|
||||
cdls() {
|
||||
cd $1 && ls
|
||||
}
|
||||
tc() {
|
||||
touch $1 && code $1
|
||||
}
|
||||
tv() {
|
||||
touch $1 && nvim $1
|
||||
}
|
||||
mt() {
|
||||
mkdir -p $(dirname $1) && touch $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
|
||||
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"
|
||||
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"
|
||||
fi
|
||||
|
||||
# `-s` suffix alias
|
||||
# % readme.md -> glow readme.md
|
||||
alias -s {md,markdown}=glow
|
||||
alias -s {htm,html,css,scss,js,jsx,ts,tsx,json,jsonc}=code
|
||||
alias -s {py,rb,pl,php,java,c,cpp,h,hpp}=nvim
|
||||
alias -s {cs,csx,fs,fsx,razor}=code
|
||||
|
||||
# TODO: Does not work
|
||||
if [ "$TERM" = "xterm-ghostty" ] || [ "$TERM" = "xterm-kitty" ]; then
|
||||
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
|
||||
fi
|
||||
43
dot_config/zsh/mod/config.zsh
Normal file
43
dot_config/zsh/mod/config.zsh
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# $DOTFILES/tools/zsh/mod/config.zsh
|
||||
# Date: 2024-11-30
|
||||
# Author: js0ny
|
||||
# Sourced by user's zshrc 在用户的 zshrc 中被引用
|
||||
|
||||
# ZSH Config, no need to `export` these variables
|
||||
HISTFILE="$XDG_STATE_HOME"/zsh/history
|
||||
HIST_STAMPS="yyyy-mm-dd"
|
||||
HISTSIZE=10000
|
||||
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"
|
||||
)
|
||||
|
||||
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
|
||||
done
|
||||
|
||||
# https://unix.stackexchange.com/questions/33994/
|
||||
# Use `set -k` to mark leading `#` as a comment character
|
||||
set -k
|
||||
|
||||
source <(fzf --zsh)
|
||||
10
dot_config/zsh/mod/env.zsh
Normal file
10
dot_config/zsh/mod/env.zsh
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# $DOTFILES/tools/zsh/mod/env.zsh
|
||||
# Date: 2024-11-30
|
||||
# Author: js0ny
|
||||
# Sourced by user's zshrc 在用户的 zshrc 中被引用
|
||||
|
||||
# This file stores only environment variables that only called by
|
||||
# interactive session.
|
||||
# 这个文件只存储只在交互式会话中调用的环境变量。
|
||||
|
||||
export IPYTHONDIR="$XDG_CONFIG_HOME"/ipython
|
||||
50
dot_config/zsh/mod/keymap.zsh
Normal file
50
dot_config/zsh/mod/keymap.zsh
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
# $DOTFILES/tools/zsh/mod/keymap.zsh
|
||||
# Date: 2024-11-30
|
||||
# Author: js0ny
|
||||
# Sourced by user's zshrc 在用户的 zshrc 中被引用
|
||||
|
||||
# read key: `fish_key_reader`
|
||||
# get current bindings: `bindkey`
|
||||
|
||||
bindkey -v # Vi Keybindings
|
||||
|
||||
# Colemak hnei
|
||||
# ^
|
||||
# n
|
||||
# < h i >
|
||||
# e
|
||||
# v
|
||||
# bindkey -M vicmd 'h' vi-backward-char # No change
|
||||
# bindkey -M vicmd 'n' down-line-or-history
|
||||
# bindkey -M vicmd 'e' up-line-or-history
|
||||
# bindkey -M vicmd 'i' vi-forward-char
|
||||
#
|
||||
# # Similar position to [i] in QWERTY
|
||||
# bindkey -M vicmd 'l' vi-insert
|
||||
# bindkey -M vicmd 'L' vi-insert-bol
|
||||
# # Ne{[k]s}t
|
||||
# bindkey -M vicmd 'k' vi-repeat-search
|
||||
# bindkey -M vicmd 'K' vi-rev-repeat-search
|
||||
# # [J]ump
|
||||
# bindkey -M vicmd 'j' vi-forward-word-end
|
||||
# bindkey -M vicmd 'J' vi-forward-blank-word-end
|
||||
# # Use N to Join
|
||||
# bindkey -M vicmd 'N' vi-join
|
||||
|
||||
# Emacs Hybrid
|
||||
bindkey '^A' beginning-of-line
|
||||
bindkey '^E' end-of-line
|
||||
bindkey '^F' forward-char
|
||||
bindkey '^B' backward-char
|
||||
bindkey '^P' up-line-or-history
|
||||
bindkey '^N' down-line-or-history
|
||||
bindkey '^R' history-incremental-search-backward
|
||||
bindkey '^K' kill-line
|
||||
# Zsh will parse <C-Backspace> to C-h
|
||||
bindkey '^H' backward-kill-word
|
||||
|
||||
# LEADER CONVENTION
|
||||
# ^X defines as a prefix key in shell
|
||||
# ^A defines as a prefix key in tmux
|
||||
# ^B defines as a prefix key in Terminal Emulators
|
||||
# SPC defines as a prefix key in nvim
|
||||
38
dot_config/zsh/mod/navi.zsh
Normal file
38
dot_config/zsh/mod/navi.zsh
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# $DOTFILES/tools/zsh/mod/navi.zsh
|
||||
# Date: 2024-12-01
|
||||
# Author: js0ny
|
||||
# Sourced by user's zshrc 在用户的 zshrc 中被引用
|
||||
|
||||
# Define __CD_CMD as "cd" by default
|
||||
__CD_CMD="cd"
|
||||
|
||||
# If zoxide is available, use it
|
||||
if command -v zoxide >/dev/null; then
|
||||
__CD_CMD="z"
|
||||
eval "$(zoxide init zsh)"
|
||||
fi
|
||||
|
||||
# Define aliases for quick navigation
|
||||
alias ..="$__CD_CMD .."
|
||||
alias ...="$__CD_CMD ../.."
|
||||
alias ....="$__CD_CMD ../../.."
|
||||
alias .....="$__CD_CMD ../../../.."
|
||||
alias ......="$__CD_CMD ../../../../.."
|
||||
|
||||
# Abbreviation for "cd -"
|
||||
alias - "$__CD_CMD -"
|
||||
|
||||
# Define zls function for cd + ls
|
||||
zls() {
|
||||
"$__CD_CMD" "$1" && ls
|
||||
}
|
||||
alias cdls=zls
|
||||
|
||||
# Quick Jump Directories
|
||||
[[ -d "$DOTFILES" ]] && alias dot="$__CD_CMD $DOTFILES"
|
||||
[[ -d "$HOME/Downloads" ]] && alias down="$__CD_CMD $HOME/Downloads"
|
||||
[[ -d "$HOME/.config" ]] && alias conf="$__CD_CMD $HOME/.config"
|
||||
[[ -d "$HOME/Obsidian" ]] && alias ob="$__CD_CMD $HOME/Obsidian"
|
||||
[[ -d "$HOME/Source" ]] && alias src="$__CD_CMD $HOME/Source"
|
||||
[[ -d "$HOME/Source/Scripts" ]] && alias scr="$__CD_CMD $HOME/Source/Scripts"
|
||||
[[ -d "$HOME/OrgFiles" ]] && alias org="$__CD_CMD $HOME/OrgFiles"
|
||||
6
dot_config/zsh/mod/prompt.zsh
Normal file
6
dot_config/zsh/mod/prompt.zsh
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# $DOTFILES/tools/zsh/mod/prompt.zsh
|
||||
# Date: 2024-11-30
|
||||
# Author: js0ny
|
||||
# Sourced by user's zshrc 在用户的 zshrc 中被引用
|
||||
|
||||
eval "$(starship init zsh)"
|
||||
Loading…
Add table
Add a link
Reference in a new issue