-
Notifications
You must be signed in to change notification settings - Fork 0
/
.yashrc
82 lines (73 loc) · 2.37 KB
/
.yashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# vim: ft=sh
# prediction
set --le-predict --le-prompt-sp
# 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-insert '\^L' clear-and-redraw-all
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=~/.yash_history HISTSIZE=5000
# prompt
hostname=$(uname -n)
if [ -n "${SSH_CONNECTION-}" ]; then
hostcolor='\fy.' # yellow hostname for SSH remote
elif [ "${hostname#*.}" != "$hostname" ]; then
hostcolor='\fb.' # blue hostname for distrobox
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
}
PS1=$usercolor'$(whoami)'$hostcolor'@$(uname -n)\fd. '\
'$(echo "$PWD" | sed "s/\/home\/rai/~/")'\
'\fc.$(git_branch)\fd.\n$ '
unset hostcolor usercolor hostname
# color predictions as dim
PS1P='\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