z_mirror/dotfiles
git clone https://git.raiguard.me/z_mirror/dotfiles
4fe2db6
uraya-alpine
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# # keybindings 23# bindkey --vi-insert '\^A' beginning-of-line 24# bindkey --vi-insert '\^B' backward-char 25# bindkey --vi-insert '\^D' eof-or-delete 26# bindkey --vi-insert '\#' eof-or-delete 27# bindkey --vi-insert '\^E' end-of-line 28# bindkey --vi-insert '\^F' forward-char 29# bindkey --vi-insert '\^K' forward-kill-line 30# bindkey --vi-insert '\^N' beginning-search-forward 31# bindkey --vi-insert '\^O' clear-candidates 32# bindkey --vi-insert '\^P' beginning-search-backward 33# bindkey --vi-insert '\^U' backward-kill-line 34# bindkey --vi-insert '\$' backward-kill-line 35# bindkey --vi-insert '\^W' backward-delete-viword 36# bindkey --vi-insert '\^Y' put-left 37# bindkey --vi-insert '\N' complete-next-column 38# bindkey --vi-insert '\P' complete-prev-column 39# bindkey --vi-command '\^N' beginning-search-forward 40# bindkey --vi-command '\^P' beginning-search-backward 41 42# normally yash is more POSIX-compliant than /bin/sh :-) 43sh() { yash --posix "$@"; } 44yash() { command yash "$@"; } 45 46# ensure job control works as expected 47case $- in (*m*) 48 trap - TSTP TTIN TTOU 49esac 50 51# command history 52HISTFILE="${XDG_CONFIG_DIR:-~/.config}/yash/history" 53HISTSIZE=5000 54 55# prompt 56hostname=$(uname -n) 57if [ -n "${SSH_CONNECTION-}" ]; then 58 hostcolor='\fy.' # yellow hostname for SSH remote 59else 60 hostcolor='\fg.' # green hostname for local 61fi 62if [ "$(id -u)" -eq 0 ]; then 63 usercolor='\fr.' # red username for root 64else 65 usercolor=$hostcolor hostcolor= # same username color as hostname for non-root user 66fi 67git_branch() { 68 branch=$(git -C "$PWD" rev-parse --abbrev-ref HEAD 2>/dev/null) 69 if [ -n "$branch" ]; then 70 echo " ($branch)" 71 fi 72} 73container_id() { 74 if [ -n "$CONTAINER_ID" ]; then 75 echo " [$CONTAINER_ID]" 76 fi 77} 78PS1=$usercolor'$(whoami)'$hostcolor'@$(uname -n)'\ 79'\fb.$(container_id)'\ 80'\fd. '\ 81'$(echo "$PWD" | sed "s/\/home\/rai/~/")'\ 82'\fc.$(git_branch) '\ 83'\fd.\n$ ' 84unset hostcolor usercolor hostname 85# color predictions as dim 86PS1P='\fi.' 87 88if [ "$TERM" == "foot" ]; then 89 # insert special escape codes for foot terminal 90 foot_escs() { 91 # update window title 92 title=$(echo $PWD | sed 's/\/home\/rai/~/') 93 printf "\033];%s\a" "$title" >&2 94 # jump between shell prompts 95 printf "%b" "\e]7;file://$(uname -n)${PWD}\e\\" 96 # open new terminals in PWD 97 printf '%b' '\e]133;A\e\\' 98 } 99 PROMPT_COMMAND=foot_escs 100fi 101 102# enable zoxide integration 103eval "$(zoxide init posix --hook prompt)" 104 105# aliases 106alias dmenu="fuzzel -d" 107alias n=nnn 108alias k="kak" 109alias sk="sudoedit" 110alias dlg="lazygit --work-tree $HOME --git-dir $HOME/.dotfiles" 111alias dgit="git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME" 112alias lg=lazygit 113alias ipconfig="nmcli dev show wlp170s0 | grep IP4" 114 115# PC-specific configuration 116if [ -f "~/.yashrc_$(uname -n)" ]; then 117 . "~/.yashrc_$(uname -n)" 118fi