From 0939a3fb4046e7d323ab95723ce64a3309f0fcaa Mon Sep 17 00:00:00 2001 From: Hadeed Ahmad Date: Wed, 13 Nov 2024 04:34:44 +0500 Subject: [PATCH] clean up zsh config --- bin/write_symbol_map.py | 45 ------------------ config/starship.toml | 11 ----- config/user-dirs.dirs | 7 --- docs/pacman_pkgs.txt | 19 -------- home/dot-zshenv | 5 +- kitty/keys.conf | 26 ----------- kitty/kitty.conf | 42 ++++++++++++----- kitty/ssh.conf | 8 +--- zsh/dot-zshenv | 17 ------- zsh/dot-zshrc | 100 +++++++++++++++++++++++++++++++++++++--- zsh/zsh-aliases | 16 ------- zsh/zsh-bindings | 8 ---- zsh/zsh-completion | 14 ------ zsh/zsh-functions | 26 ----------- zsh/zsh-options | 30 ------------ 15 files changed, 129 insertions(+), 245 deletions(-) delete mode 100755 bin/write_symbol_map.py delete mode 100644 config/starship.toml delete mode 100644 docs/pacman_pkgs.txt delete mode 100644 kitty/keys.conf delete mode 100644 zsh/dot-zshenv delete mode 100644 zsh/zsh-aliases delete mode 100644 zsh/zsh-bindings delete mode 100644 zsh/zsh-completion delete mode 100644 zsh/zsh-functions delete mode 100644 zsh/zsh-options diff --git a/bin/write_symbol_map.py b/bin/write_symbol_map.py deleted file mode 100755 index b553582..0000000 --- a/bin/write_symbol_map.py +++ /dev/null @@ -1,45 +0,0 @@ -#! /usr/bin/env python3 - -import os -import shutil -import subprocess -import sys - -font_file = "/usr/share/fonts/TTF/SymbolsNerdFontMono-Regular.ttf" -if not os.path.exists(font_file): - sys.stderr.write("Error: The font file does not exist.\n") - sys.exit(1) - -if shutil.which("otfinfo") is None: - sys.stderr.write("Error: otfinfo not found.\n") - sys.exit(1) - -def create_maps(numbers): - start = numbers[0] - end = start - maps = [] - - for number in numbers[1:]: - if number == end + 1: - end = number - else: - codepoints = f"U+{start:X}" if start == end else f"U+{start:X}-U+{end:X}" - maps.append(f"symbol_map {codepoints} Symbols Nerd Font Mono") - - start = end = number - - codepoints = f"U+{start:X}" if start == end else f"U+{start:X}-U+{end:X}" - maps.append(f"symbol_map {codepoints} Symbols Nerd Font Mono") - - return maps - -output = subprocess.check_output(f"otfinfo -u {font_file} | cut -c4-7", shell=True, text=True) -numbers = [int(line.strip(), 16) for line in output.strip().split('\n')] -maps = create_maps(numbers) - -symbol_map_file = os.path.join(os.getenv("HOME"), ".config", "kitty", "symbol_map.conf") -with open(symbol_map_file, "w") as file: - for map in maps: - file.write(f"{map}\n") - -print("Symbol map written successfully!") diff --git a/config/starship.toml b/config/starship.toml deleted file mode 100644 index 4580085..0000000 --- a/config/starship.toml +++ /dev/null @@ -1,11 +0,0 @@ -[python] -symbol=" " - -[lua] -symbol=" " - -[golang] -symbol=" " - -[gcloud] -symbol="󱇶 " diff --git a/config/user-dirs.dirs b/config/user-dirs.dirs index 00fa1ae..460231a 100644 --- a/config/user-dirs.dirs +++ b/config/user-dirs.dirs @@ -1,10 +1,3 @@ -# This file is written by xdg-user-dirs-update -# If you want to change or add directories, just edit the line you're -# interested in. All local changes will be retained on the next run. -# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped -# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an -# absolute path. No other format is supported. - XDG_DESKTOP_DIR="$HOME" XDG_DOWNLOAD_DIR="$HOME/dl" XDG_TEMPLATES_DIR="$HOME" diff --git a/docs/pacman_pkgs.txt b/docs/pacman_pkgs.txt deleted file mode 100644 index b8ced64..0000000 --- a/docs/pacman_pkgs.txt +++ /dev/null @@ -1,19 +0,0 @@ -bat -docker -docker-compose -exa -fd -grub-customizer -kitty -neovim -pyenv -qmk -ripgrep -starship -ttf-jetbrains-mono -ttf-nerd-fonts-symbols-mono -xclip -xdg-desktop-portal-gnome -zsh - -# texlive-bin=2023.66984-8 diff --git a/home/dot-zshenv b/home/dot-zshenv index e5dfd59..36ecd4a 100644 --- a/home/dot-zshenv +++ b/home/dot-zshenv @@ -1,5 +1,8 @@ export ZDOTDIR="$HOME/.config/zsh" -[ -e "$ZDOTDIR/.zshenv" ] && . "$ZDOTDIR/.zshenv" +typeset -U path +path+="$HOME/bin" + +export DOTS="$HOME/docs/repos/dots" # vim: filetype=zsh diff --git a/kitty/keys.conf b/kitty/keys.conf deleted file mode 100644 index 9fd6380..0000000 --- a/kitty/keys.conf +++ /dev/null @@ -1,26 +0,0 @@ -clear_all_shortcuts yes -kitty_mod ctrl+shift - -map kitty_mod+c copy_to_clipboard -map kitty_mod+v paste_from_clipboard - -map kitty_mod+p scroll_line_up -map kitty_mod+n scroll_line_down -map kitty_mod+u scroll_page_up -map kitty_mod+d scroll_page_down -map kitty_mod+g show_last_command_output -map kitty_mod+g launch --stdin-source=@last_cmd_output --stdin-add-formatting --type=overlay less +G -r - -map kitty_mod+equal change_font_size all +1.0 -map kitty_mod+minus change_font_size all -1.0 -map kitty_mod+backspace change_font_size all 0 - -map kitty_mod+enter new_window -map kitty_mod+k next_window -map kitty_mod+j previous_window -map kitty_mod+q close_window - -map kitty_mod+t new_tab -map kitty_mod+l next_tab -map kitty_mod+h previous_tab -map kitty_mod+o select_tab diff --git a/kitty/kitty.conf b/kitty/kitty.conf index 829fe4e..2453c2c 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -1,20 +1,38 @@ +symbol_map U+e000-U+e00a,U+ea60-U+ebeb,U+e0a0-U+e0c8,U+e0ca,U+e0cc-U+e0d7,U+e200-U+e2a9,U+e300-U+e3e3,U+e5fa-U+e6b1,U+e700-U+e7c5,U+ed00-U+efc1,U+f000-U+f2ff,U+f000-U+f2e0,U+f300-U+f372,U+f400-U+f533,U+f0001-U+f1af0 Symbols Nerd Font Mono font_family JetBrains Mono font_size 12.0 -enable_audio_bell no disable_ligatures cursor - -scrollback_lines 65536 - +enable_audio_bell no enabled_layouts tall -tab_bar_style hidden hide_window_decorations yes +scrollback_lines 65536 +tab_bar_style hidden + +clear_all_shortcuts yes +kitty_mod ctrl+shift + +map kitty_mod+c copy_to_clipboard +map kitty_mod+v paste_from_clipboard + +map kitty_mod+p scroll_line_up +map kitty_mod+n scroll_line_down +map kitty_mod+u scroll_page_up +map kitty_mod+d scroll_page_down +map kitty_mod+g show_last_command_output + +map kitty_mod+equal change_font_size all +1.0 +map kitty_mod+minus change_font_size all -1.0 +map kitty_mod+backspace change_font_size all 0 + +map kitty_mod+enter new_window +map kitty_mod+k next_window +map kitty_mod+j previous_window +map kitty_mod+q close_window + +map kitty_mod+t new_tab +map kitty_mod+l next_tab +map kitty_mod+h previous_tab +map kitty_mod+o select_tab -include keys.conf -include symbol_map.conf include themes/gruvbox.conf - -allow_remote_control socket-only -listen_on unix:/tmp/kitty -action_alias kitty_scrollback_nvim kitten /home/hadeed/.local/share/nvim/lazy/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py -map kitty_mod+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output diff --git a/kitty/ssh.conf b/kitty/ssh.conf index 4fc496f..5034255 100644 --- a/kitty/ssh.conf +++ b/kitty/ssh.conf @@ -1,6 +1,2 @@ -env ZDOTDIR=$HOME/.config/zsh -env REMOTE_HOST=1 - -copy --dest .config/zsh --exclude 'dot-' $DOTS/zsh -copy --dest .config/zsh/.zshenv $DOTS/zsh/dot-zshenv -copy --dest .config/zsh/.zshrc $DOTS/zsh/dot-zshrc +copy --dest .zshrc $DOTS/zsh/dot-zshrc +remote_kitty if-needed diff --git a/zsh/dot-zshenv b/zsh/dot-zshenv deleted file mode 100644 index b6dea61..0000000 --- a/zsh/dot-zshenv +++ /dev/null @@ -1,17 +0,0 @@ -typeset -U path -path+="$HOME/bin" -path+="$HOME/.local/npm/bin" -path+="$HOME/.dotnet/tools" - -export DOTS="$HOME/docs/repos/dots" - -export VISUAL="nvim" -export EDITOR="nvim" - -export npm_config_prefix="$HOME/.local/npm" - -if command -v pyenv &> /dev/null; then - eval "$(pyenv init -)" -fi - -# vim: filetype=zsh diff --git a/zsh/dot-zshrc b/zsh/dot-zshrc index b8147e3..2493f0b 100644 --- a/zsh/dot-zshrc +++ b/zsh/dot-zshrc @@ -1,6 +1,5 @@ function create_dir() [ ! -d "$1" ] && mkdir -p "$1" function safe_source() [ -f "$1" ] && source "$1" -function zsh_add_file() safe_source "$ZDOTDIR/$1" function zsh_add_plugin() { PLUGIN_NAME=$(echo $1 | cut -d "/" -f 2) @@ -11,17 +10,104 @@ function zsh_add_plugin() { safe_source "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME/$PLUGIN_NAME.zsh" } -zsh_add_file "zsh-aliases" -zsh_add_file "zsh-functions" -zsh_add_file "zsh-options" -zsh_add_file "zsh-completion" +if (( $+commands[starship] )); then + source <(starship init zsh) +else + [ ! -d "$HOME/.local/share/zsh/plugins/pure" ] && + git clone "https://github.com/sindresorhus/pure" "$HOME/.local/share/zsh/plugins/pure" + + fpath+="$HOME/.local/share/zsh/plugins/pure" + safe_source "$HOME/.local/share/zsh/plugins/pure/pure.zsh" +fi + +zsh_add_plugin "mattmc3/ez-compinit" + +zstyle ":completion:*" list-colors ${(s.:.)LS_COLORS} +zstyle ":completion:*" matcher-list "m:{a-z}={A-Za-z}" +zstyle ":completion:*" menu no +zstyle ":completion:*:descriptions" format "[%d]" +zstyle ":completion:*:git-checkout:*" sort false +zstyle ":fzf-tab:complete:cd:*" fzf-preview "eza -1 --color=always $realpath" + +create_dir "$HOME/.local/state/zsh" + +HISTFILE="$HOME/.local/state/zsh/history" +HISTSIZE=65536 +SAVEHIST=$HISTSIZE + +setopt AUTO_CD +setopt HIST_IGNORE_DUPS +setopt HIST_VERIFY +setopt INC_APPEND_HISTORY +setopt MULTIOS +setopt NO_BEEP +setopt RM_STAR_SILENT + +stty stop undef +zle_highlight=("paste:none") zsh_add_plugin "Aloxaf/fzf-tab" -zsh_add_plugin "ahmubashshir/zinsults" zsh_add_plugin "zdharma-continuum/fast-syntax-highlighting" zsh_add_plugin "zsh-users/zsh-autosuggestions" zsh_add_plugin "zsh-users/zsh-completions" -zsh_add_file "zsh-bindings" +ZVM_INIT_MODE=sourcing +ZVM_VI_INSERT_ESCAPE_BINDKEY=jk +zsh_add_plugin "jeffreytse/zsh-vi-mode" +ZVM_LINE_INIT_MODE=$ZVM_MODE_INSERT +ZVM_INSERT_MODE_CURSOR=$ZVM_CURSOR_BLINKING_BEAM + +export VISUAL="nvim" +export EDITOR="nvim" + +if (( $+commands[pyenv] )); then + source <(pyenv init -) +fi + +if (( $+commands[fzf] )); then + source <(fzf --zsh) +fi + +autoload -z edit-command-line +zle -N edit-command-line +bindkey "^V" edit-command-line +bindkey "^Y" autosuggest-execute +bindkey "^F" fzf-cd-widget + +############################################################################### +# FUNCTIONS # +############################################################################### + +function cc() python -c "from math import *; print($*)" +alias cc="noglob cc" + +############################################################################### +# ALIASES # +############################################################################### + +if [[ -f /etc/os-release ]]; then + source /etc/os-release + + if [[ "$ID_LIKE" == *"arch"* ]]; then + alias p="sudo pacman -S" + alias pu="sudo pacman -Syu" + elif [[ "$ID" == "debian" || "$ID_LIKE" == *"debian"* ]]; then + alias p="sudo apt install" + alias pu="sudo apt update && sudo apt upgrade" + fi +fi + +alias vi="nvim" + +alias l="eza -x --group-directories-first --icons" +alias la="l -a" + +alias ll="l -lbh --git --no-time" +alias lla="ll -a" + +alias lt="ll --tree" +alias lta="lt -a --ignore-glob=".git"" + +alias s="kitty +kitten ssh" # vim: filetype=zsh diff --git a/zsh/zsh-aliases b/zsh/zsh-aliases deleted file mode 100644 index 9452013..0000000 --- a/zsh/zsh-aliases +++ /dev/null @@ -1,16 +0,0 @@ -alias p='sudo pacman -S' -alias pu='sudo pacman -Syu' - -alias vi='nvim' - -alias l='exa -x --group-directories-first --icons' -alias ll='l -lbh --git --no-time' -alias lt='ll --tree' - -alias la='l -a' -alias lla='ll -a' -alias lta='lt -a --ignore-glob=".git"' - -alias s='kitty +kitten ssh' - -# vim: filetype=zsh diff --git a/zsh/zsh-bindings b/zsh/zsh-bindings deleted file mode 100644 index b2108e9..0000000 --- a/zsh/zsh-bindings +++ /dev/null @@ -1,8 +0,0 @@ -autoload -z edit-command-line -zle -N edit-command-line -bindkey "^V" edit-command-line - -bindkey '^Y' autosuggest-execute -bindkey '^F' find-directory - -# vim: filetype=zsh diff --git a/zsh/zsh-completion b/zsh/zsh-completion deleted file mode 100644 index d81cf0d..0000000 --- a/zsh/zsh-completion +++ /dev/null @@ -1,14 +0,0 @@ -create_dir "$HOME/.cache/zsh" -autoload -Uz compinit -compinit -d "$HOME/.cache/zsh/zcompdump" -zmodload zsh/complist - -zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' -zstyle ':completion:*:git-*:*' sort false -zstyle ':completion:*:descriptions' format '[%d]' -zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} - -zstyle ':fzf-tab:*' fzf-bindings 'space:accept' -zstyle ':fzf-tab:*' accept-line enter - -# vim: filetype=zsh diff --git a/zsh/zsh-functions b/zsh/zsh-functions deleted file mode 100644 index 71bab79..0000000 --- a/zsh/zsh-functions +++ /dev/null @@ -1,26 +0,0 @@ -function cc() python -c "from math import *; print($*)" -alias cc='noglob cc' - -function save-ssh-key() { - mkdir -p "$HOME/.ssh" - chmod 700 "$HOME/.ssh" - - mv "$1" "$HOME/.ssh/${1}_${2}" - - if [ -e "$1.pub" ]; then - mv -n "$1.pub" "$HOME/.ssh/${1}_${2}.pub" - fi -} - -function find-directory() { - FOLDER=$(fd -t d --hidden | fzf --height="~50%" --reverse) - if [ -n "$FOLDER" ]; then - BUFFER="cd $FOLDER; l" - zle .accept-line - else - zle reset-prompt - fi -} -zle -N find-directory - -# vim: filetype=zsh diff --git a/zsh/zsh-options b/zsh/zsh-options deleted file mode 100644 index 8f15707..0000000 --- a/zsh/zsh-options +++ /dev/null @@ -1,30 +0,0 @@ -create_dir "$HOME/.local/state/zsh" - -HISTFILE="$HOME/.local/state/zsh/history" -HISTSIZE=65536 -SAVEHIST=$HISTSIZE - -setopt AUTO_CD -setopt HIST_IGNORE_DUPS -setopt HIST_VERIFY -setopt INC_APPEND_HISTORY -setopt RM_STAR_SILENT -setopt NO_BEEP -setopt MULTIOS - -bindkey -e - -stty stop undef -zle_highlight=("paste:none") - -if command -v starship &> /dev/null; then - eval "$(starship init zsh)" -else - [ ! -d "$HOME/.local/share/zsh/plugins/pure" ] && - git clone "https://github.com/sindresorhus/pure" "$HOME/.local/share/zsh/plugins/pure" - - fpath+="$HOME/.local/share/zsh/plugins/pure" - safe_source "$HOME/.local/share/zsh/plugins/pure/pure.zsh" -fi - -# vim: filetype=zsh