feat(shell): Use one keymaps for shell

This commit is contained in:
js0ny 2025-01-28 14:26:25 +00:00
parent 68ff1bb357
commit 2346c13564
19 changed files with 530 additions and 265 deletions

View file

@ -8,37 +8,37 @@ alias ni=touch
alias cls=clear
alias ii=open
# Editors #
alias v=nvim
alias c=code
# Use neovide as gVim
alias gvi="neovide"
alias sv="sudo vim -u ~/.dotfiles/common/vim.noxdg.vimrc"
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 for Python
alias pip=pip3 # Alias for pip
# alias bashcfg="nvim ~/.bashrc"
alias zshcfg="nvim $ZDOTDIR/.zshrc"
alias shcfg=zshcfg
alias reload="source $ZDOTDIR/.zshrc"
alias nvimrc="nvim $XDG_CONFIG_HOME/nvim/"
alias pulldots="cd $DOTFILES && git pull"
alias py=python
alias ipy=ipython
alias reload="source $ZDOTDIR/.zshrc"
# Editors #
alias v=nvim
alias c=code
alias sv="sudo vim -u ~/.dotfiles/common/vim.noxdg.vimrc"
alias sn="sudo nvim -u ~/.config/nvim/init.lua"
# lsd - modern ls
if command -v lsd > /dev/null; then
alias ls='lsd -A -I .DS_Store -I .git'
alias ls='lsd -A'
alias l='lsd -lah'
alias ll='lsd -l'
alias tree='lsd --tree -I .DS_Store -I .git -A'
alias tree='lsd --tree -A'
else
alias l='ls -lah'
alias ll='ls -l'
fi
# fzf - Fuzzy Finder
# export FZF_DEFAULT_OPTS_FILE=~/.dotfiles/common/fzfrc
# Functions #
mkcd() {
@ -54,21 +54,6 @@ tv(){
touch $1 && nvim $1
}
# Use neovide as gVim
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
}
alias update="source $DOTFILES/scripts/update.zsh"
@ -93,7 +78,21 @@ if command -v brew > /dev/null; then
alias brewr="brew uninstall"
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 {md,markdown}=code
alias -s {py,sh,rb,pl,php,java,c,cpp,h,hpp}=nvim
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

View file

@ -20,14 +20,18 @@ 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

View file

@ -4,6 +4,9 @@
# Sourced by user's zshrc 在用户的 zshrc 中被引用
# read key: `fish_key_reader`
# get current bindings: `bindkey`
bindkey -v # Vi Keybindings
# Colemak hnei
@ -38,6 +41,8 @@ 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

View file

@ -3,19 +3,7 @@
# Author: js0ny
# Sourced by user's zshrc 在用户的 zshrc 中被引用
# Relative navigation #
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ......="cd ../../../../.."
# Use `-` to jump to the previous directory
# Oh-My-Zsh defines a similar one
function - { cd - }
# Use `z` to jump to a directory
eval "$(zoxide init zsh)"
# Absolute navigation #
alias dotfiles="cd $DOTFILES && ls"
@ -37,5 +25,29 @@ 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 gdrive="cd $HOME/Google Drive"
fi
if command -v zoxide > /dev/null ; 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
}
else
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ......="cd ../../../../.."
alias - "cd -"
fi

1
tools/zsh/zprofile Normal file
View file

@ -0,0 +1 @@
export FZF_DEFAULT_OPTS_FILE="$DOTFILES/common/fzfrc"