Auto-venv
is a Fish shell script that automatically activates and deactivates Python virtual environments when entering/leaving directory that contains virtual environment.
Recently, I added multiple enhancements compare to the upstream version, now it handles edge cases more gracefully:
It safely manages virtual environment inheritance in new shell sessions.
It prevents shell exits during the activation and deactivation processes.
Here is the most valuable part of my emacs
vTerm
config with fish shell.
add source vterm.fish to your fish shell configuration file
use edit <file> in vTerm buffer will open file at the new window above vTerm buffer, similar to using code <file> in VSCode embedded terminal.
vterm.fish
# https://github.com/akermu/emacs-libvtermfunction vterm_printf
if begin
[ -n "$TMUX"]; and string match -q -r "screen|tmux""$TERM" end
# tell tmux to pass the escape sequences throughprintf"\ePtmux;\e\e]%s\007\e\\""$argv"elseif string match -q -- "screen*""$TERM"# GNU screen (screen, screen-256color, screen-256color-bce)printf"\eP\e]%s\007\e\\""$argv"elseprintf"\e]%s\e\\""$argv" end
end
function vterm_cmd --description 'Run an Emacs command among the ones been defined in vterm-eval-cmds.'set -l vterm_elisp ()for arg in $argvset -a vterm_elisp (printf'"%s" '(string replace -a -r '([\\\\"])''\\\\\\\\$1'$arg)) end
vterm_printf '51;E'(string join ''$vterm_elisp)end
if["$INSIDE_EMACS"= vterm ]set -gx EDITOR code
function clear
vterm_printf "51;Evterm-clear-scrollback" tput clear
end
# used by vterm buffer namefunction fish_title
hostname
echo":" prompt_pwd
end
function vterm_prompt_end --on-variable PWD
vterm_printf '51;A'(whoami)'@'(hostname)':'(pwd) end
function edit
set -q argv[1]; or set argv[1]"." vterm_cmd vterm-edit-file (realpath "$argv") end
end
doom emacs config
config.el
(after!vterm(defunvterm-edit-file(file)"Open a file from vterm in another window, keeping only the vterm window and the new file window."(interactive)(let((current-vterm-window(catch'found(dolist(win(window-list))(when(and(window-live-pwin)(eq'vterm-mode(buffer-local-value'major-mode(window-bufferwin))))(throw'foundwin)))))new-file-window)(whencurrent-vterm-window;; Open file in a new window from current VTerm window(select-windowcurrent-vterm-window)(setqnew-file-window(split-window-below)); Adjust split direction to preference(set-window-buffernew-file-window(find-file-noselectfile));; Delete all other windows except for VTerm and the new file window(mapc(lambda(win)(unless(or(eqwincurrent-vterm-window)(eqwinnew-file-window))(delete-windowwin)))(window-list))(select-windownew-file-window))))(add-to-list'vterm-eval-cmds'("vterm-edit-file"vterm-edit-file)))
[core]pager=delta[interactive]diffFilter=delta --color-only[delta]navigate=true # use n and N to move between diff sections
light = false # set to true if you're in a terminal w/ a light background color (e.g. the default macOS terminal)[merge]conflictstyle=diff3[diff]colorMoved=default
# Add HomeBrew's bin directory to path so you can use HomeBrew's binaries like `starship`# Fish uses `fish_add_path` instead of `export PATH` modify $PATH.fish_add_path "/opt/homebrew/bin/"# Enable Starship promptstarship init fish |source
abbr proxyall "set --export http_proxy http://127.0.0.1:7890; set --export https_proxy http://127.0.0.1:7890"
custom function
it’s very easy to add a custom function in fish shell,
an example
Visual Studio Code
Settings
Side Bar:Location change to right
extensions
Auto Hide
AutoTrim
Emacs Friendly Keymap
Indenticator
Sort lines
vscode-icons
Python
use
pyenv
to manage Python environments, don’t reply on the python installed by brew, because it might update Python version upexpecetdly when performs brew update.
brew install readline xz pyenv
# otpinal: setup pyenv with fish shellaliasbrew="env PATH=(string replace (pyenv root)/shims '' \"\$PATH\") brew"exec"$SHELL"pyenv install 3.11.6
pyenv global 3.11.6