1
0
Fork 0

small changes

This commit is contained in:
Luca Bilke 2023-03-26 15:17:48 +02:00
parent efc70e0cdd
commit 7ae39ff2e9
4 changed files with 10 additions and 15 deletions

View File

@ -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"

View File

@ -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}.."

2
TODO
View File

@ -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