z_mirror/dotfiles
git clone https://git.raiguard.me/z_mirror/dotfiles
6e7ce75
tangere
1# vim: ft=sh 2 3if [ ! $YASH_PROFILE_LOADED ]; then 4 . ~/.yash_profile 5fi 6 7# prediction 8set --le-predict --le-prompt-sp 9 10# most users are more familiar with emacs mode than vi mode 11if [ -o vi ]; then 12 set --emacs 13fi 14 15bindkey --emacs '\^N' beginning-search-forward 16bindkey --emacs '\^O' clear-candidates 17bindkey --emacs '\^P' beginning-search-backward 18bindkey --emacs '\N' complete-next-column 19bindkey --emacs '\P' complete-prev-column 20bindkey --emacs '\^L' clear-and-redraw-all 21 22# normally yash is more POSIX-compliant than /bin/sh :-) 23sh() { yash --posix "$@"; } 24yash() { command yash "$@"; } 25 26# ensure job control works as expected 27case $- in (*m*) 28 trap - TSTP TTIN TTOU 29esac 30 31# command history 32set --hist-space # Don't save commands starting with a space in the history 33HISTFILE=${XDG_STATE_HOME:-~/.local/state}/yash/history 34HISTSIZE=5000 35 36# prompt 37hostname=$(uname -n) 38if [ -n "${SSH_CONNECTION-}" ]; then 39 hostcolor='\fy.' # yellow hostname for SSH remote 40else 41 hostcolor='\fg.' # green hostname for local 42fi 43if [ "$(id -u)" -eq 0 ]; then 44 usercolor='\fr.' # red username for root 45else 46 usercolor=$hostcolor hostcolor= # same username color as hostname for non-root user 47fi 48git_branch() { 49 branch=$(git -C "$PWD" rev-parse --abbrev-ref HEAD 2>/dev/null) 50 if [ -n "$branch" ]; then 51 echo " ($branch)" 52 fi 53} 54container_id() { 55 if [ -n "$CONTAINER_ID" ]; then 56 echo " [distrobox:$CONTAINER_ID]" 57 fi 58} 59shpool_session() { 60 if [ -n "$SHPOOL_SESSION_NAME" ]; then 61 echo " [shpool:$SHPOOL_SESSION_NAME]" 62 fi 63} 64PS1=$usercolor'$(whoami)'$hostcolor'@$(uname -n)'\ 65'\fb.$(container_id)'\ 66'$(shpool_session)'\ 67'\fd. '\ 68'$(echo "$PWD" | sed "s/\/home\/rai/~/")'\ 69'\fc.$(git_branch)'\ 70'${{?:/0/}:+\fr. [$?]\fd.}'\ 71'\fd.\n$ ' 72unset hostcolor usercolor hostname 73# color predictions as dim 74PS1P='\fi.' 75 76if [ "$TERM" == "foot" ]; then 77 # insert special escape codes for foot terminal 78 foot_escs() { 79 # update window title 80 title=$(echo "foot: $PWD" | sed 's/\/home\/rai/~/') 81 printf "\033];%s\a" "$title" >&2 82 # jump between shell prompts 83 printf "%b" "\e]7;file://$(uname -n)${PWD}\e\\" 84 # open new terminals in PWD 85 printf '%b' '\e]133;A\e\\' 86 } 87 PROMPT_COMMAND=foot_escs 88fi 89 90# enable zoxide integration 91eval "$(zoxide init posix --hook prompt)" 92 93# aliases 94alias dmenu="fuzzel -d" 95alias sk="sudoedit" 96alias dlg="lazygit --work-tree $HOME --git-dir $HOME/.dotfiles" 97alias dgit="git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME" 98alias lg=lazygit 99alias ipconfig="nmcli dev show wlp170s0 | grep IP4"