From c52c7f314ccadcc2fcd91e28c8fd1b88f6d5ce0c Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Fri, 18 Oct 2024 17:07:46 +0200 Subject: refactor(modules): Move all system modules to `by-name` From now on all modules should be added to the new `by-name` directory. This should help remove the (superficial and utterly useless) distinction between `home-manager` and `NixOS` modules. --- modules/home/conf/zsh/config/command_not_found.sh | 64 ----- .../conf/zsh/config/command_not_found_insult.sh | 298 --------------------- modules/home/conf/zsh/config/custom_cursor.zsh | 42 --- modules/home/conf/zsh/config/zsh-init.zsh | 42 --- 4 files changed, 446 deletions(-) delete mode 100644 modules/home/conf/zsh/config/command_not_found.sh delete mode 100644 modules/home/conf/zsh/config/command_not_found_insult.sh delete mode 100644 modules/home/conf/zsh/config/custom_cursor.zsh delete mode 100644 modules/home/conf/zsh/config/zsh-init.zsh (limited to 'modules/home/conf/zsh/config') diff --git a/modules/home/conf/zsh/config/command_not_found.sh b/modules/home/conf/zsh/config/command_not_found.sh deleted file mode 100644 index fb21b676..00000000 --- a/modules/home/conf/zsh/config/command_not_found.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env dash - -# This was taken from the -# `${pkgs.nix-index}/etc/profile.d/command-not-found.sh` file on 2024-02-28 - -# for bash 4 -# this will be called when a command is entered -# but not found in the user’s path + environment -command_not_found_handle() { - # taken from http://www.linuxjournal.com/content/bash-command-not-found - # - do not run when inside Midnight Commander or within a Pipe - if [ -n "${MC_SID-}" ] || ! [ -t 1 ]; then - >&2 echo "$1: command not found" - return 127 - fi - - toplevel=nixpkgs # nixpkgs should always be available even in NixOS - cmd="$1" - attrs=$(nix-locate --minimal --no-group --type x --type s --top-level --whole-name --at-root "/bin/$cmd") - len=$(if [ -n "$attrs" ]; then echo "$attrs" | wc -l; else echo 0; fi) - - case "$len" in - 0) - eprintln "$cmd: command not found" - ;; - 1) - # If only one package provides this, then we can invoke it - # without asking the user. - - # These will not return 127 if they worked correctly. - - >&2 cat <&2 cat <&2 cat <&2 - fi -} - -function_exists() { - # Zsh returns 0 even on non existing functions with -F so use -f - declare -f "$1" >/dev/null - return $? -} - -# -# The idea below is to copy any existing handlers to another function -# name and insert the message in front of the old handler in the -# new handler. By default, neither bash or zsh has has a handler function -# defined, so the default behaviour is replicated. -# -# Also, ensure the handler is only copied once. If we do not ensure this -# the handler would add itself recursively if this file happens to be -# sourced multiple times in the same shell, resulting in a neverending -# stream of messages. -# - -# -# Zsh -# -if function_exists command_not_found_handler; then - if ! function_exists orig_command_not_found_handler; then - eval "orig_$(declare -f command_not_found_handler)" - fi -else - orig_command_not_found_handler() { - printf "zsh: command not found: %s\n" "$1" >&2 - return 127 - } -fi - -command_not_found_handler() { - print_message - orig_command_not_found_handler "$@" -} - -# -# Bash -# -if function_exists command_not_found_handle; then - if ! function_exists orig_command_not_found_handle; then - eval "orig_$(declare -f command_not_found_handle)" - fi -else - orig_command_not_found_handle() { - printf "%s: %s: command not found\n" "$0" "$1" >&2 - return 127 - } -fi - -command_not_found_handle() { - print_message - orig_command_not_found_handle "$@" -} diff --git a/modules/home/conf/zsh/config/custom_cursor.zsh b/modules/home/conf/zsh/config/custom_cursor.zsh deleted file mode 100644 index 37390c1c..00000000 --- a/modules/home/conf/zsh/config/custom_cursor.zsh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env zsh - -# Change cursor shape for different vi modes. -function zle-keymap-select { - if [[ ${KEYMAP} == vicmd ]] || - [[ $1 = 'block' ]]; then - echo -ne '\e[1 q' - elif [[ ${KEYMAP} == main ]] || - [[ ${KEYMAP} == viins ]] || - [[ ${KEYMAP} = '' ]] || - [[ $1 = 'beam' ]]; then - echo -ne '\e[5 q' - fi -} -zle -N zle-keymap-select - -# ci", ci', ci`, di", etc -autoload -U select-quoted -zle -N select-quoted -for m in visual viopp; do - for c in {a,i}{\',\",\`}; do - bindkey -M "$m" "$c" select-quoted - done -done - -# ci{, ci(, ci<, di{, etc -autoload -U select-bracketed -zle -N select-bracketed -for m in visual viopp; do - for c in {a,i}${(s..)^:-'()[]{}<>bB'}; do - bindkey -M $m $c select-bracketed - done -done - -zle-line-init() { - zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere) - echo -ne "\e[5 q" -} -zle -N zle-line-init - -echo -ne '\e[5 q' # Use beam shape cursor on startup. -precmd() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt. diff --git a/modules/home/conf/zsh/config/zsh-init.zsh b/modules/home/conf/zsh/config/zsh-init.zsh deleted file mode 100644 index cd8d34a9..00000000 --- a/modules/home/conf/zsh/config/zsh-init.zsh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env zsh -# If not running interactively, don't do anything -[[ $- != *i* ]] && return - -# Flex on the ubuntu users -#[ "$NVIM" ] || hyfetch -[ "$NVIM" ] || task next -#loginctl show-session $XDG_SESSION_ID - -## Enable colors and change prompt: -#autoload -Uz colors && colors -#autoload -Uz compinit && compinit -u -## Edit line in vim buffer ctrl-v -autoload -Uz edit-command-line -zle -N edit-command-line -## Enter vim buffer from normal mode -#autoload -Uz edit-command-line && zle -N edit-command-line -bindkey "^V" edit-command-line - -## zstyles -#zstyle ':completion:*' menu select -## Auto complete with case insensitivity -#zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' - -#zmodload zsh/complist -#fpath+=/home/dt/.config/zsh/comp -#compinit -#_comp_options+=(globdots) # Include hidden files. -# -## Source configs -#source "${ZDOTDIR}/ali.sh" -#source "${ZDOTDIR}/prompt.sh" -#source "${ZDOTDIR}/hotkeys.sh" -#source "./${path_custom_cursor}" -#source ~/.local/lib/shell/lib -# -## Load zsh-syntax-highlighting -#source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh -## Suggest aliases for commands -#source /usr/share/zsh/plugins/zsh-you-should-use/you-should-use.plugin.zsh -# -##eval "$(lua ~/scripts/z.lua --init zsh enhanced)" -- cgit 1.4.1