summaryrefslogtreecommitdiff
path: root/.bashrc
blob: 8dc90a32c2f3f4f65d5ae6ac9e0c1e616da77b88 (plain) (blame)
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
# If not running interactively, don’t do anything
[[ $- != *i* ]] && return
[ -f /etc/bashrc ] && . /etc/bashrc

function __dir_search {
	local qry="$1"
	local base="$2"
	shift 2

	local dir=$(
		find "$base" "$@" -type d -printf '%P\n' \
		| sed 1i. \
		| sort -r \
		| fzf -q "$qry"
	)
	[ -n "$dir" ] && pushd "$base/$dir"
}

function jr {
	__dir_search "$1" "$REPODIR" -mindepth 2 -maxdepth 2
}

function jc {
	__dir_search "$1" "$XDG_CONFIG_HOME" -maxdepth 1 -type d
}

function goto {
	local dst="$(fzf --literal --filepath-word --walker=dir --walker-root="$HOME")" \
	&& pushd "$dst"
}

alias irssi='irssi --config="$XDG_CONFIG_HOME/irssi/config" --home="$XDG_DATA_HOME/irssi"'
alias ..='cd ..'
alias d='git --git-dir="$REPODIR/@me/dotfiles.git" --work-tree="$HOME"'
alias g=git
alias grep='grep --color=auto'
alias la='ls --color=auto -Av    --group-directories-first'
alias ll='ls --color=auto -AGhlv --group-directories-first --time-style="+%d %b %Y %T"'
alias ls='ls --color=auto -v     --group-directories-first'
alias sl='sl -ac5'
alias dv=doasedit
alias sv=sudoedit
alias v="$VISUAL"
alias z='2>/dev/null zathura --fork "$@" 2>/dev/null'

__ps1_newline() {
	local _ y x _
	local RESET="\e[0m"
	local HL="\e[30;47m"

	IFS='[;' read -p $'\e[6n' -d R -rs _ y x _
	[[ "$x" != 1 ]] && printf "${HL}␀\n${RESET}"
}

PS1="\$(__ps1_newline)"'\[\e[96;1m\]\u \[\e[39m\]\W \[\e[96m\]〉\[\e[0m\]'

command -v fzf >/dev/null && eval "$(fzf --bash)"
command -v niri >/dev/null && eval "$(niri completions bash)"

if [ -d "$NVM_DIR" ]
then
	. "$NVM_DIR/nvm.sh"
	. "$NVM_DIR/bash_completion"
fi