diff options
author | Martin Fischer <martin@push-f.com> | 2024-12-27 08:45:34 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2024-12-27 18:44:37 +0100 |
commit | 1b65ba7a838e422c9bf16ddcaf796a996fa51b6b (patch) | |
tree | d8ec8d965f955a7f9a5c2b5c98e8a430fb0e8b6f /user/zsh/zshrc-workstation.sh | |
parent | edda7ef46bf2ae7fde9511005b4e7d40648c7e24 (diff) |
refactor: introduce profiles
Diffstat (limited to 'user/zsh/zshrc-workstation.sh')
-rw-r--r-- | user/zsh/zshrc-workstation.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/user/zsh/zshrc-workstation.sh b/user/zsh/zshrc-workstation.sh new file mode 100644 index 0000000..04f9c88 --- /dev/null +++ b/user/zsh/zshrc-workstation.sh @@ -0,0 +1,42 @@ +# This file is sourced by .zshrc if profiles/workstation was imported. + +## Aliases +alias code='codium' +alias tokei='tokei -s code -n commas' + +## Environment variables +export NPM_CONFIG_PREFIX="$HOME/.local/npm" + +path+=~/.cargo/bin +path+=($NPM_CONFIG_PREFIX/bin) + +function ssh() { + # In my ~/.ssh/config I configure host-specific background colors, for example: + # + # Host forest + # LocalCommand set-bg 003300 + # + # Since SSH doesn't provide a way of running a command on exit, this shell + # function takes care of resetting the background color on exit. + + # Note that we're setting PermitLocalCommand=yes here rather than in + # .ssh/config because the latter makes git over SSH fail with: + # + # fatal: protocol error: bad line length character: ?]11 + command ssh -o PermitLocalCommand=yes "$@"; reset-bg +} + +if [ $TERM = foot ]; then + # Enable spawning of new terminal instances in the current working directory + function osc7-pwd() { + emulate -L zsh # also sets localoptions for us + setopt extendedglob + local LC_ALL=C + printf '\e]7;file://%s%s\e\' $HOST ${PWD//(#m)([^@-Za-z&-;_~])/%${(l:2::0:)$(([##16]#MATCH))}} + } + + function chpwd-osc7-pwd() { + (( ZSH_SUBSHELL )) || osc7-pwd + } + add-zsh-hook -Uz chpwd chpwd-osc7-pwd +fi |