# vim: ft=sh if [ ! $YASH_PROFILE_LOADED ]; then . ~/.config/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 # 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 set --hist-space # Don't save commands starting with a space in the history HISTFILE=${XDG_STATE_HOME:-~/.local/state}/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 " [distrobox:$CONTAINER_ID]" fi } shpool_session() { if [ -n "$SHPOOL_SESSION_NAME" ]; then echo " [shpool:$SHPOOL_SESSION_NAME]" fi } rtm_session() { if [ -n "$RTM_SESSION_NAME" ]; then echo " [rtm:$RTM_SESSION_NAME]" fi } PS1=$usercolor'$(whoami)'$hostcolor'@$(uname -n)'\ '\fb.$(container_id)'\ '$(shpool_session)'\ '$(rtm_session)'\ '\fd. '\ '$(echo "$PWD" | sed "s/\/home\/rai/~/")'\ '\fc.$(git_branch)'\ '${{?:/0/}:+\fr. [$?]\fd.}'\ '\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 "foot: $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 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"