From 2ee16a671eda9b0e56cc2454b0aae260e03fa9d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Sun, 26 Oct 2025 20:28:46 +0100 Subject: [PATCH] Add zsh and alias --- private_dot_config/shell/alias | 26 +++++++++++ private_dot_config/zsh/dot_zshrc | 76 ++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 private_dot_config/shell/alias create mode 100644 private_dot_config/zsh/dot_zshrc diff --git a/private_dot_config/shell/alias b/private_dot_config/shell/alias new file mode 100644 index 0000000..db5dfd5 --- /dev/null +++ b/private_dot_config/shell/alias @@ -0,0 +1,26 @@ +#!/bin/sh +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# some more ls aliases +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' +alias mv="mv --interactive --verbose" +alias rm="rm --interactive --verbose" +alias cp="cp --verbose" +alias cat='batcat --plain' +alias lsbc="lsblk | batcat --language=conf --plain" +alias bathelp='batcat --plain --language=help' +help() { + "$@" --help 2>&1 | bathelp +} diff --git a/private_dot_config/zsh/dot_zshrc b/private_dot_config/zsh/dot_zshrc new file mode 100644 index 0000000..60a4c99 --- /dev/null +++ b/private_dot_config/zsh/dot_zshrc @@ -0,0 +1,76 @@ +# source global shell alias & variables files +[ -f "$XDG_CONFIG_HOME/shell/alias" ] && source "$XDG_CONFIG_HOME/shell/alias" +[ -f "$XDG_CONFIG_HOME/shell/vars" ] && source "$XDG_CONFIG_HOME/shell/vars" + +# Set up the prompt +#autoload -Uz promptinit +#promptinit +#prompt adam1 + +# man opt +export MANPAGER="sh -c 'col -bx | batcat --language=man --plain'" +export MANROFFOPT="-c" + +setopt histignorealldups sharehistory + +# Use emacs keybindings even if our EDITOR is set to vi +bindkey -e + +# Use modern completion system +autoload -Uz compinit +autoload -Uz colors +compinit +colors + +zstyle ':completion:*' auto-description 'specify: %d' +zstyle ':completion:*' completer _expand _complete _correct _approximate +zstyle ':completion:*' format 'Completing %d' +zstyle ':completion:*' group-name '' +zstyle ':completion:*' menu select=2 +eval "$(dircolors -b)" +zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} +zstyle ':completion:*' list-colors '' +zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s +zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*' +zstyle ':completion:*' menu select=long +zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s +zstyle ':completion:*' use-compctl false +zstyle ':completion:*' verbose true + +zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' +zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' + +# colored GCC warnings and errors +#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# main opts +setopt append_history inc_append_history share_history +# on exit, history appends rather than overwrites; history is appended as soon as cmds executed; history shared across sessions +setopt auto_menu menu_complete # autocmp first menu match +setopt autocd # type a dir to cd +setopt auto_param_slash # when a dir is completed, add a / instead of a trailing space +setopt no_case_glob no_case_match # make cmp case insensitive +setopt globdots # include dotfiles +setopt extended_glob # match ~ # ^ +setopt interactive_comments # allow comments in shell +unsetopt prompt_sp # don't autoclean blanklines +stty stop undef # disable accidental ctrl s + +# history opts +HISTFILE="$XDG_CACHE_HOME/zsh_history" # move histfile to cache +HISTCONTROL=ignoreboth # consecutive duplicates & commands starting with space are not saved +HISTSIZE=1000 +SAVEHIST=1000 + +# fzf setup +#source <(fzf --zsh) # allow for fzf history widget + +# set up prompt +NEWLINE=$'\n' +PROMPT="${NEWLINE}%K{#2E3440}%F{#E5E9F0} %N %K{#3b4252}%F{#ECEFF4} %n %K{#4c566a} %~ %f%k ❯ " # nord theme + +echo -e "${NEWLINE}\x1b[38;5;137m\x1b[48;5;0m it's $(print -P '%D{%_H:%M%P}\n') \x1b[38;5;180m\x1b[48;5;0m $(uptime -p | cut -c 4-) \x1b[38;5;223m\x1b[48;5;0m $(uname -r) \033[0m" # current + +# syntax highlighting +# requires zsh-syntax-highlighting package +#source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh