dots/private_dot_elvish/rc.elv

99 lines
2.6 KiB
Plaintext

use path
use str
use platform
use github.com/zzamboni/elvish-modules/iterm2
use github.com/xiaq/edit.elv/smart-matcher
use github.com/zzamboni/elvish-modules/alias
# Initialize iTerm2 support
iterm2:init
smart-matcher:apply
# Convenience function for only setting PATH if the specified directory exists
setpath = [path]{
if (path:is-dir $path) {
set-env PATH (str:join ':' [$E:PATH $path])
}
}
# Set paths
$setpath ~/n/bin
$setpath /opt/homebrew/bin
$setpath ~/.rbenv/shims
$setpath ~/.rbenv/bin
$setpath ~/.cargo/bin
$setpath ~/.local/bin
# Use private stuff
if (path:is-regular ~/.elvish/lib/private.elv) {
use private
private:init
}
# Environment variables
set-env EDITOR "vim"
set-env USER "lu"
set-env SHELL (which elvish)
set-env TERM xterm-256color
set-env N_PREFIX ~/n
set-env LANG en_US.UTF-8
set-env LC_ALL en_US.UTF-8
set-env LANGUAGE en_US.UTF-8
set-env RUST_SRC_PATH (and (has-external rustc) (rustc --print sysroot))/lib/rustlib/src/rust/src
set-env PYTHONPATH (str:join ':' ["/Users/lu/.local/pipx/venvs/pdm/lib/python3.9/site-packages/pdm/pep582" $E:PYTHONPATH])
set-env TZ_LIST "Europe/Berlin;Berlin,America/New_York;US East,America/Los_Angeles;US West,Europe/London;London"
set-env MANPAGER "sh -c 'col -bx | bat -l man -p'"
# If Systemd is not installed and we're on Linux, set XDG_RUNTIME_DIR
if (and (eq (has-external systemctl) $false) $platform:is-unix) {
set-env XDG_RUNTIME_DIR /run/user/(id -u)
}
# Aliases
alias:new editconfig chezmoi edit ~/.elvish/rc.elv
alias:new reload eval (cat ~/.elvish/rc.elv | slurp)
alias:new c cargo
alias:new cr cargo run
alias:new cb cargo build
alias:new cwr cargo watch -x run
alias:new mkt cd (mktemp -d)
alias:new czm chezmoi
# Git aliases
alias:new g git
alias:new gaa git add --all
alias:new gs git status
alias:new gl git log --color --graph --abbrev-commit --oneline
alias:new gpl git pull
alias:new gps git push
alias:new gc git commit
# Mercurial aliases
alias:new h hg
alias:new ha hg addremove
alias:new hc hg commit
alias:new hps hg push
alias:new hpl hg pull
alias:new hs hg status
alias:new hl hg log
# XBPS aliases
alias:new xi sudo xbps-install
alias:new xq xbps-query
# Aliases that overwrite other, existing commands
alias:new ls exa
# Abbreviations
edit:small-word-abbr["g"] = "git"
edit:small-word-abbr["h"] = "hg"
edit:small-word-abbr["gco"] = "git checkout"
# Prompt
edit:prompt = { styled (tilde-abbr $pwd) green; put "\n> " }
edit:rprompt = (constantly "")
# Nice welcome message
if (and (has-external toilet) (has-external lolcat)) {
toilet -f future "Welcome to elvish!" | lolcat -F 0.4 -S (randint 1 100)
} else {
echo "Welcome to elvish! To enable gay mode, install `toilet` and `lolcat`."
}