From 701377dad16e96a4436880a51afc82acb45c0157 Mon Sep 17 00:00:00 2001 From: eneller Date: Wed, 1 Mar 2023 09:28:19 +0100 Subject: [PATCH] improve shell config --- .config/shell/alias.sh | 34 +++++----------------------------- .config/tmux/tmux.conf | 2 +- .config/zsh/.zshrc | 36 +++++++++++++++++++++++++++++------- .config/zsh/p10k.zsh | 1 + 4 files changed, 36 insertions(+), 37 deletions(-) diff --git a/.config/shell/alias.sh b/.config/shell/alias.sh index 69ab0be..2225324 100644 --- a/.config/shell/alias.sh +++ b/.config/shell/alias.sh @@ -1,13 +1,13 @@ -alias ls='ls -hN --group-directories-first --color=auto' # make output more readable and show directories first +alias ls='exa' # make output more readable and show directories first alias ll='ls -l' -alias la='ls --almost-all' -alias grep='grep --color=auto' # colorize grep output, set GREP_COLORS +alias la='ls --all' +alias grep='rg' # colorize grep output, set GREP_COLORS alias cp="cp -i" # Confirm before overwriting something alias df='df -h' # Human-readable sizes -alias free='free -m' alias vi='nvim' # Show sizes in MB alias r='R' +alias xar="xarchiver" # Add an "alert" alias for long running commands. Use like so: 'sleep 10; alert' alias notify='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' @@ -50,32 +50,8 @@ title() echo -e "\e]2;$1\007"; } -# -# # ex - archive extractor -# # usage: ex -ex () -{ - if [ -f $1 ] ; then - case $1 in - *.tar.bz2) tar xjf $1 ;; - *.tar.gz) tar xzf $1 ;; - *.bz2) bunzip2 $1 ;; - *.rar) unrar x $1 ;; - *.gz) gunzip $1 ;; - *.tar) tar xf $1 ;; - *.tbz2) tar xjf $1 ;; - *.tgz) tar xzf $1 ;; - *.zip) unzip $1 ;; - *.Z) uncompress $1;; - *.7z) 7z x $1 ;; - *) echo "'$1' cannot be extracted via ex()" ;; - esac - else - echo "'$1' is not a valid file" - fi -} - pwd() { echo "$PWD/$1" } + diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf index 06dae27..acd9db0 100644 --- a/.config/tmux/tmux.conf +++ b/.config/tmux/tmux.conf @@ -1,5 +1,5 @@ tmux_config_dir="~/.config/tmux" -mod="C-a" +mod="C-b" #CONFIGURATION #if-shell '[[ -n "$SSH_CLIENT"]]' { # source-file $tmux_config_dir/tmux_remote.conf # use alternative config for tmux inside ssh session diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 65e1c7c..3550440 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -1,5 +1,3 @@ - - #OPTIONS SECTION #unsetopt beep # try disabling annoying beep sounds @@ -107,7 +105,8 @@ source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zs #ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]=fg=009 #ZSH_HIGHLIGHT_STYLES[assign]=none - [[ ! -f "$ZDOTDIR/p10k.zsh" ]] || source "$ZDOTDIR/p10k.zsh" # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. + [[ ! -f "$ZDOTDIR/p10k.zsh" ]] || source "$ZDOTDIR/p10k.zsh" # To customize prompt, run `p10k configure` or edit ~/.config/zsh/p10k.zsh + #eval "$(starship init zsh)" # starship.rs prompt to replace p10k source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh # load fish-completion, needs to be sourced after syntax highlighting @@ -134,7 +133,30 @@ source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh # l #elif [[ -f /etc/DIR_COLORS ]] ; then # eval $(dircolors -b /etc/DIR_COLORS) #fi - - - - +# +function command_not_found_handler { + local purple='\e[1;35m' bright='\e[0;1m' green='\e[1;32m' reset='\e[0m' + printf 'zsh: command not found: %s\n' "$1" + local entries=( + ${(f)"$(/usr/bin/pacman -F --machinereadable -- "/usr/bin/$1")"} + ) + if (( ${#entries[@]} )) + then + printf "${bright}$1${reset} may be found in the following packages:\n" + local pkg + for entry in "${entries[@]}" + do + # (repo package version file) + local fields=( + ${(0)entry} + ) + if [[ "$pkg" != "${fields[2]}" ]] + then + printf "${purple}%s/${bright}%s ${green}%s${reset}\n" "${fields[1]}" "${fields[2]}" "${fields[3]}" + fi + printf ' /%s\n' "${fields[4]}" + pkg="${fields[2]}" + done + fi + return 127 +} diff --git a/.config/zsh/p10k.zsh b/.config/zsh/p10k.zsh index bd3ac57..3d871d1 100644 --- a/.config/zsh/p10k.zsh +++ b/.config/zsh/p10k.zsh @@ -903,6 +903,7 @@ typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER= # Custom icon. # typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + typeset -g POWERLEVEL9K_VIRTUALENV_GENERIC_NAMES=(virtualenv venv .venv env .env) #####################[ anaconda: conda environment (https://conda.io/) ]###################### # Anaconda environment color.