From c2af11facbf452fe5d504d65c27ac19a32c0d526 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Thu, 31 Mar 2022 08:53:13 +0200 Subject: Added change conda environment on cd in zshrc --- config/zsh/.zshrc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'config/zsh/.zshrc') diff --git a/config/zsh/.zshrc b/config/zsh/.zshrc index 92c55c5..b524a17 100644 --- a/config/zsh/.zshrc +++ b/config/zsh/.zshrc @@ -59,10 +59,23 @@ export SAVEHIST=5000 # executed when changing directory chpwd() { + # ls on cd if not too much files content="$(find . -maxdepth 1 | wc -l)" ([ "$content" -lt 20 ] && ls -l) || echo "$(pwd) contains $content entries" [ "$(uname)" = 'Linux' ] && [ "$(stat -c "%U" .)" = "$USER" ] && touch . # to sort by last cd + + + # change conda env if name of the directory is the name of an env + [ ! -d "$PWD/.git" ] && return + name="$(basename "$PWD")" + [ "$name" = $CONDA_DEFAULT_ENV ] && return + conda env list | + cut -d ' ' -f 1 | + sed -e '/^#/d' -e '/^$/d' -e '/^base$/d' | + grep -q "$name" && + conda activate "$name" + } # https://wiki.archlinux.org/title/Zsh#Shortcut_to_exit_shell_on_partial_command_line @@ -96,3 +109,31 @@ if [ "$(uname)" = 'Linux' ] then . /usr/share/doc/pkgfile/command-not-found.zsh fi + +# upload-config() { +# scp -qr "$HOME/.vim" cce424r@ds-train: +# scp -q "$HOME/.config/vim/vimrc" cce424r@ds-train:.vimrc +# +# scp -qr "$HOME/.vim" cce424r@ds-attic: +# scp -q "$HOME/.config/vim/vimrc" cce424r@ds-attic:.vimrc +# } + +# >>> conda initialize >>> +# !! Contents within this block are managed by 'conda init' !! +__conda_setup="$('/usr/local/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)" +if [ $? -eq 0 ]; then + eval "$__conda_setup" +else + if [ -f "/usr/local/anaconda3/etc/profile.d/conda.sh" ]; then + . "/usr/local/anaconda3/etc/profile.d/conda.sh" + else + export PATH="/usr/local/anaconda3/bin:$PATH" + fi +fi +unset __conda_setup + +if [ -f "/usr/local/anaconda3/etc/profile.d/mamba.sh" ]; then + . "/usr/local/anaconda3/etc/profile.d/mamba.sh" +fi +# <<< conda initialize <<< + -- cgit From ca5b53db1e8ce9f7f5c33cd9ddcda63d460942e0 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Wed, 27 Apr 2022 06:04:56 +0200 Subject: Added nvim vim-slime plugin, Updated zsh chpwd hook to cache conda env list command --- config/zsh/.zshrc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'config/zsh/.zshrc') diff --git a/config/zsh/.zshrc b/config/zsh/.zshrc index b524a17..bde98eb 100644 --- a/config/zsh/.zshrc +++ b/config/zsh/.zshrc @@ -65,17 +65,16 @@ chpwd() { echo "$(pwd) contains $content entries" [ "$(uname)" = 'Linux' ] && [ "$(stat -c "%U" .)" = "$USER" ] && touch . # to sort by last cd - # change conda env if name of the directory is the name of an env [ ! -d "$PWD/.git" ] && return name="$(basename "$PWD")" [ "$name" = $CONDA_DEFAULT_ENV ] && return - conda env list | + [ ! -e "$HOME/conda_envs" ] && conda env list > "$HOME/conda_envs" + < "$HOME/conda_envs" \ cut -d ' ' -f 1 | sed -e '/^#/d' -e '/^$/d' -e '/^base$/d' | grep -q "$name" && conda activate "$name" - } # https://wiki.archlinux.org/title/Zsh#Shortcut_to_exit_shell_on_partial_command_line -- cgit From d624f6863538b1dc9e4dc62fabc66168adbede24 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Wed, 18 May 2022 14:15:03 +0200 Subject: Updated zsh extension ignore to inclue the dot (otherwise .go files got ignored) --- config/zsh/.zshrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config/zsh/.zshrc') diff --git a/config/zsh/.zshrc b/config/zsh/.zshrc index bde98eb..9e9f583 100644 --- a/config/zsh/.zshrc +++ b/config/zsh/.zshrc @@ -85,7 +85,7 @@ zle -N exit_zsh bindkey '^D' exit_zsh # shellcheck disable=SC2034,SC2039,SC3030 -fignore=(o hi) # ignore extensions in autocomplete +fignore=(.o .hi) # ignore extensions in autocomplete # set tab to 4 spaces tabs 4 -- cgit From 414a32702300e073d221d462599dd92f11ed9411 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Fri, 10 Jun 2022 15:34:37 +0200 Subject: Added ocaml neovim lsp, removing gutentags --- config/zsh/.zshrc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'config/zsh/.zshrc') diff --git a/config/zsh/.zshrc b/config/zsh/.zshrc index 9e9f583..e7dac3d 100644 --- a/config/zsh/.zshrc +++ b/config/zsh/.zshrc @@ -66,15 +66,15 @@ chpwd() { [ "$(uname)" = 'Linux' ] && [ "$(stat -c "%U" .)" = "$USER" ] && touch . # to sort by last cd # change conda env if name of the directory is the name of an env - [ ! -d "$PWD/.git" ] && return - name="$(basename "$PWD")" - [ "$name" = $CONDA_DEFAULT_ENV ] && return - [ ! -e "$HOME/conda_envs" ] && conda env list > "$HOME/conda_envs" - < "$HOME/conda_envs" \ - cut -d ' ' -f 1 | - sed -e '/^#/d' -e '/^$/d' -e '/^base$/d' | - grep -q "$name" && - conda activate "$name" + # [ ! -d "$PWD/.git" ] && return + # name="$(basename "$PWD")" + # [ "$name" = $CONDA_DEFAULT_ENV ] && return + # [ ! -e "$HOME/conda_envs" ] && conda env list > "$HOME/conda_envs" + # < "$HOME/conda_envs" \ + # cut -d ' ' -f 1 | + # sed -e '/^#/d' -e '/^$/d' -e '/^base$/d' | + # grep -q "$name" && + # conda activate "$name" } # https://wiki.archlinux.org/title/Zsh#Shortcut_to_exit_shell_on_partial_command_line @@ -136,3 +136,4 @@ if [ -f "/usr/local/anaconda3/etc/profile.d/mamba.sh" ]; then fi # <<< conda initialize <<< +eval "$(opam env)" -- cgit