From 7ae39ff2e93f935f497bc5a70354e586c50d8255 Mon Sep 17 00:00:00 2001 From: Luca Bilke Date: Sun, 26 Mar 2023 15:17:48 +0200 Subject: [PATCH] small changes --- .cache/zsh/{.keep => history} | 0 .config/zsh/.zshrc | 19 ++++++++----------- .../{autopyenv.plugin.zsh => autopyenv.zsh} | 4 ++-- TODO | 2 -- 4 files changed, 10 insertions(+), 15 deletions(-) rename .cache/zsh/{.keep => history} (100%) rename .local/share/zsh/plugins/autopyenv/{autopyenv.plugin.zsh => autopyenv.zsh} (81%) diff --git a/.cache/zsh/.keep b/.cache/zsh/history similarity index 100% rename from .cache/zsh/.keep rename to .cache/zsh/history diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 2295ac64a..214360a9c 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -3,9 +3,6 @@ autoload edit-command-line && zle -N edit-command-line autoload -U add-zsh-hook autoload -U compinit autoload -Uz edit-command-line - -source ${ZDOTDIR:-$HOME}/.kubernetesrc_ansible - PS1="%B%F{blue}%n%F{cyan}@%F{blue}%m %F{magenta}[%f%3~%F{magenta}] %(?.%F{green}.%F{red})ยป%f%b " RPS1="%(?..%F{red}%?)" stty stop undef # Disable ctrl-s to freeze terminal. @@ -39,6 +36,7 @@ bindkey -M menuselect 'k' vi-up-line-or-history bindkey -M menuselect 'l' vi-forward-char bindkey -M menuselect 'j' vi-down-line-or-history + # Change cursor shape for different vi modes. function zle-keymap-select () { case $KEYMAP in @@ -56,7 +54,7 @@ echo -ne '\e[5 q' # Use beam shape cursor on startup. preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt. # Use lf to switch directories and bind it to ctrl-o -lfcd () { +function lfcd () { tmp="$(mktemp)" fid="$(mktemp)" lf -command '$printf $id > '"$fid"'' -last-dir-path="$tmp" "$@" @@ -82,7 +80,7 @@ lfcd () { tput cuu1;tput el } -_lfcd () { +function _lfcd () { BUFFER="lfcd" zle accept-line } @@ -90,7 +88,7 @@ zle -N _lfcd bindkey '^e' _lfcd # bind lazygit to ctrl-g -lg () { +function lg () { [ ! -d "$(pwd)/.git" ] && [[ $(read -ek "?Not in a git repository. Create a new git repository? (y/n): ") =~ ^[Yy]$ ]] && git init [ -d "$(pwd)/.git" ] && lazygit -p $(pwd) zle reset-prompt @@ -98,11 +96,10 @@ lg () { zle -N lg{,} bindkey '^g' lg -# This function simply writes the venv of the last executed command to a file to be read by external status indicators -function write_venv(){ - echo -n "${VIRTUAL_ENV:t}" > "/tmp/current_venv-$$" +function write_info(){ + echo -n "${VIRTUAL_ENV}" > "/tmp/current_venv-$$" } -add-zsh-hook precmd write_venv +add-zsh-hook precmd write_info # other keybinds bindkey -v '^?' backward-delete-char @@ -118,4 +115,4 @@ zle_highlight+=(paste:none) PLUGINS_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins" [ -f "$PLUGINS_HOME/fzf/key-bindings.zsh" ] && source "$PLUGINS_HOME/fzf/key-bindings.zsh" [ -f "$PLUGINS_HOME/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh" ] && source "$PLUGINS_HOME/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh" -[ -f "$PLUGINS_HOME/autopyenv/autopyenv.plugin.zsh" ] && source "$PLUGINS_HOME/autopyenv/autopyenv.plugin.zsh" +[ -f "$PLUGINS_HOME/autopyenv/autopyenv.zsh" ] && source "$PLUGINS_HOME/autopyenv/autopyenv.zsh" diff --git a/.local/share/zsh/plugins/autopyenv/autopyenv.plugin.zsh b/.local/share/zsh/plugins/autopyenv/autopyenv.zsh similarity index 81% rename from .local/share/zsh/plugins/autopyenv/autopyenv.plugin.zsh rename to .local/share/zsh/plugins/autopyenv/autopyenv.zsh index 39b61e3d2..9049c7f28 100644 --- a/.local/share/zsh/plugins/autopyenv/autopyenv.plugin.zsh +++ b/.local/share/zsh/plugins/autopyenv/autopyenv.zsh @@ -2,7 +2,7 @@ PYENV_DIR="${PYENVS_HOME:-${XDG_DATA_HOME:-$HOME/.local/share}/virtualenv}" function chpwd_activate(){ [[ "$(pwd)" == "/" ]] && return 0 for pydir in $(ls $PYENV_DIR); do - if [[ "$(pwd|sed -e s@/@_@g|cut -c2-)" =~ "^${pydir}$" ]] || [[ "r-$(pwd|sed -e s@/@_@g|cut -c2-)" =~ "^${pydir}(_.+)?$" ]]; then + if [[ "$(pwd | sed -e 's|/|~|g' | cut -c2-)" =~ "^${pydir}$" ]] || [[ "r-$(pwd | sed -e 's|/|~|g' | cut -c2-)" =~ "^${pydir}(_.+)?$" ]]; then if [ "x$VIRTUAL_ENV" != "x$PYENV_DIR/$pydir" ]; then source "$PYENV_DIR/$pydir/bin/activate" fi @@ -16,7 +16,7 @@ function chpwd_activate(){ function venv(){ [[ "$(pwd)" == "/" ]] && echo "Cannot create venv at root" && return 1 - [[ "$(pwd)" != "/" ]] && envdir=$(pwd|sed -e s@/@_@g|cut -c2-) + [[ "$(pwd)" != "/" ]] && envdir=$(pwd | sed -e 's|/|~|g' | cut -c2-) [[ "$1" == "-r" ]] && envdir="r-$envdir" # create a venv that will be activated for all subdirectories as well if [ ! -e "$PYENV_DIR/${envdir}" ]; then echo "Creating python venv for ${envdir}.." diff --git a/TODO b/TODO index 3f0d8f72c..1e8c5777a 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,5 @@ TODO: Rework lf icons for audio and video files - TODO: Move NVIM config to submodule TODO: https://sw.kovidgoyal.net/kitty/kittens/panel/ TODO: Create a better bitwarden integration TODO: Create a brightness indicator for dunst - TODO: Fix the pyenv indicator for kitty TODO: Look into nix and their home manager