z_mirror/dotfiles

git clone https://git.raiguard.me/z_mirror/dotfiles

Caleb Heueryash: Fix profile inclusion path4ae4acd

noctalia
2.6 KiB105 linesraw
1# vim: ft=sh
2
3if [ ! $YASH_PROFILE_LOADED ]; then
4  . ~/.config/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}
64rtm_session() {
65  if [ -n "$RTM_SESSION_NAME" ]; then
66    echo " [rtm:$RTM_SESSION_NAME]"
67  fi
68}
69PS1=$usercolor'$(whoami)'$hostcolor'@$(uname -n)'\
70'\fb.$(container_id)'\
71'$(shpool_session)'\
72'$(rtm_session)'\
73'\fd. '\
74'$(echo "$PWD" | sed "s/\/home\/rai/~/")'\
75'\fc.$(git_branch)'\
76'${{?:/0/}:+\fr. [$?]\fd.}'\
77'\fd.\n$ '
78unset hostcolor usercolor hostname
79# color predictions as dim
80PS1P='\fi.'
81
82if [ "$TERM" == "foot" ]; then
83  # insert special escape codes for foot terminal
84  foot_escs() {
85    # update window title
86    title=$(echo "foot: $PWD" | sed 's/\/home\/rai/~/')
87    printf "\033];%s\a" "$title" >&2
88    # jump between shell prompts
89    printf "%b" "\e]7;file://$(uname -n)${PWD}\e\\"
90    # open new terminals in PWD
91    printf '%b' '\e]133;A\e\\'
92  }
93  PROMPT_COMMAND=foot_escs
94fi
95
96# enable zoxide integration
97eval "$(zoxide init posix --hook prompt)"
98
99# aliases
100alias dmenu="fuzzel -d"
101alias sk="sudoedit"
102alias dlg="lazygit --work-tree $HOME --git-dir $HOME/.dotfiles"
103alias dgit="git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME"
104alias lg=lazygit
105alias ipconfig="nmcli dev show wlp170s0 | grep IP4"