# vim: ft=sh if [ ! $YASH_PROFILE_LOADED ]; then . ~/.yash_profile fi # prediction set --le-predict --le-prompt-sp # most users are more familiar with emacs mode than vi mode if [ -o vi ]; then set --emacs fi bindkey --emacs '\^N' beginning-search-forward bindkey --emacs '\^O' clear-candidates bindkey --emacs '\^P' beginning-search-backward bindkey --emacs '\N' complete-next-column bindkey --emacs '\P' complete-prev-column bindkey --emacs '\^L' clear-and-redraw-all # # keybindings # bindkey --vi-insert '\^A' beginning-of-line # bindkey --vi-insert '\^B' backward-char # bindkey --vi-insert '\^D' eof-or-delete # bindkey --vi-insert '\#' eof-or-delete # bindkey --vi-insert '\^E' end-of-line # bindkey --vi-insert '\^F' forward-char # bindkey --vi-insert '\^K' forward-kill-line # bindkey --vi-insert '\^N' beginning-search-forward # bindkey --vi-insert '\^O' clear-candidates # bindkey --vi-insert '\^P' beginning-search-backward # bindkey --vi-insert '\^U' backward-kill-line # bindkey --vi-insert '\$' backward-kill-line # bindkey --vi-insert '\^W' backward-delete-viword # bindkey --vi-insert '\^Y' put-left # bindkey --vi-insert '\N' complete-next-column # bindkey --vi-insert '\P' complete-prev-column # bindkey --vi-command '\^N' beginning-search-forward # bindkey --vi-command '\^P' beginning-search-backward # normally yash is more POSIX-compliant than /bin/sh :-) sh() { yash --posix "$@"; } yash() { command yash "$@"; } # ensure job control works as expected case $- in (*m*) trap - TSTP TTIN TTOU esac # command history HISTFILE="${XDG_CONFIG_DIR:-~/.config}/yash/history" HISTSIZE=5000 # prompt hostname=$(uname -n) if [ -n "${SSH_CONNECTION-}" ]; then hostcolor='\fy.' # yellow hostname for SSH remote else hostcolor='\fg.' # green hostname for local fi if [ "$(id -u)" -eq 0 ]; then usercolor='\fr.' # red username for root else usercolor=$hostcolor hostcolor= # same username color as hostname for non-root user fi git_branch() { branch=$(git -C "$PWD" rev-parse --abbrev-ref HEAD 2>/dev/null) if [ -n "$branch" ]; then echo " ($branch)" fi } container_id() { if [ -n "$CONTAINER_ID" ]; then echo " [$CONTAINER_ID]" fi } PS1=$usercolor'$(whoami)'$hostcolor'@$(uname -n)'\ '\fb.$(container_id)'\ '\fd. '\ '$(echo "$PWD" | sed "s/\/home\/rai/~/")'\ '\fc.$(git_branch) '\ '\fd.\n$ ' unset hostcolor usercolor hostname # color predictions as dim PS1P='\fi.' if [ "$TERM" == "foot" ]; then # insert special escape codes for foot terminal foot_escs() { # update window title title=$(echo $PWD | sed 's/\/home\/rai/~/') printf "\033];%s\a" "$title" >&2 # jump between shell prompts printf "%b" "\e]7;file://$(uname -n)${PWD}\e\\" # open new terminals in PWD printf '%b' '\e]133;A\e\\' } PROMPT_COMMAND=foot_escs fi # enable zoxide integration eval "$(zoxide init posix --hook prompt)" # aliases alias dmenu="fuzzel -d" alias n=nnn alias k="kak" alias sk="sudoedit" alias dlg="lazygit --work-tree $HOME --git-dir $HOME/.dotfiles" alias dgit="git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME" alias lg=lazygit alias ipconfig="nmcli dev show wlp170s0 | grep IP4" # PC-specific configuration if [ -f "~/.yashrc_$(uname -n)" ]; then . "~/.yashrc_$(uname -n)" fi