Update

Author Mitja Felicijan <mitja.felicijan@gmail.com> 2025-02-25 09:08:30 +0100
Committer Mitja Felicijan <mitja.felicijan@gmail.com> 2025-02-25 09:08:30 +0100
Commit bb696a7fa6783e9d8bda8345fa4b7f5cb090e410 (patch)
-rwxr-xr-x .shenanigans.sh 132
-rw-r--r-- .togglesink.sh 21
2 files changed, 79 insertions, 74 deletions
diff --git a/.shenanigans.sh b/.shenanigans.sh
...
4
#   stow rsync entr vim xxd sbcl rlwrap podman podman-compose
4
#   stow rsync entr vim xxd sbcl rlwrap podman podman-compose
5
#   clang clang-tidy clang-toolsi-extra clangd clang-analyzer
5
#   clang clang-tidy clang-toolsi-extra clangd clang-analyzer
6
  
6
  
7
# Magical environment variables.
7
# Only run if the script is being sourced (bashrc).
8
export NIX_SHELL_PRESERVE_PROMPT=1
8
if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
9
export COLORTERM=truecolor
9
	# Magical environment variables.
10
export TERM=xterm-256color
10
	export NIX_SHELL_PRESERVE_PROMPT=1
11
export VISUAL=vim
11
	export COLORTERM=truecolor
12
export EDITOR=vim
12
	export TERM=xterm-256color
  
13
	export VISUAL=vim
  
14
	export EDITOR=vim
13
  
15
  
14
parse_git_branch() {
16
	parse_git_branch() {
15
	git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
17
		git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
16
}
18
	}
17
  
19
  
18
is_inside_nix_shell() {
20
	is_inside_nix_shell() {
19
	nix_shell_name="$(basename "$IN_NIX_SHELL" 2>/dev/null)"
21
		nix_shell_name="$(basename "$IN_NIX_SHELL" 2>/dev/null)"
20
	if [[ -n "$nix_shell_name" ]]; then
22
		if [[ -n "$nix_shell_name" ]]; then
21
		echo " \e[0;36m(nix-shell)\e[0m"
23
			echo " \e[0;36m(nix-shell)\e[0m"
22
	fi
24
		fi
23
}
25
	}
24
  
26
  
25
# Better prompt.
27
	# Better prompt.
26
export PS1="\n[\033[38;5;166m\]\u@\h\[$(tput sgr0)\]] \033[90m\T\033[0m$(is_inside_nix_shell)\[\033[33m\]\$(parse_git_branch)\[\033[00m\] \w\[$(tput sgr0)\] \n$ "
28
	export PS1="\n[\033[38;5;166m\]\u@\h\[$(tput sgr0)\]] \033[90m\T\033[0m$(is_inside_nix_shell)\[\033[33m\]\$(parse_git_branch)\[\033[00m\] \w\[$(tput sgr0)\] \n$ "
27
  
29
  
28
# General aliases.
30
	# General aliases.
29
alias l='ls -lh'
31
	alias l='ls -lh'
30
alias ll='ls -lha'
32
	alias ll='ls -lha'
31
alias t='tree -L 2'
33
	alias t='tree -L 2'
32
alias ..='cd ..'
34
	alias ..='cd ..'
33
alias grep='grep --color=always'
35
	alias grep='grep --color=always'
34
alias less='less -R'
36
	alias less='less -R'
35
alias tmux='tmux -u'
37
	alias tmux='tmux -u'
36
alias vi='vim'
38
	alias vi='vim'
37
alias server='python3 -m http.server 6969'
39
	alias server='python3 -m http.server 6969'
38
alias gg='lazygit'
40
	alias gg='lazygit'
39
  
41
  
40
# Custom folder jump commands.
42
	# Custom folder jump commands.
41
alias p='cd ~/Vault/projects'
43
	alias p='cd ~/Vault/projects'
42
alias j='cd ~/Junk/current'
44
	alias j='cd ~/Junk/current'
43
alias d='cd ~/Downloads'
45
	alias d='cd ~/Downloads'
44
  
46
  
45
# Additional path settings.
47
	# Additional path settings.
46
export PATH=$HOME/Applications:$PATH
48
	export PATH=$HOME/Applications:$PATH
47
export PATH=$HOME/go/bin:$PATH
49
	export PATH=$HOME/go/bin:$PATH
48
export PATH=$HOME/.local/bin:$PATH
50
	export PATH=$HOME/.local/bin:$PATH
49
export PATH=/usr/local/go/bin:$PATH
51
	export PATH=/usr/local/go/bin:$PATH
50
  
52
  
51
# Language servers.
53
	# Language servers.
52
export PATH=$HOME/.local/bin/luals/bin:$PATH
54
	export PATH=$HOME/.local/bin/luals/bin:$PATH
53
  
55
  
54
# Other stuff.
56
	# Other stuff.
55
export PATH=$HOME/Applications/riscv-gnu-toolchain/bin:$PATH
57
	export PATH=$HOME/Applications/riscv-gnu-toolchain/bin:$PATH
56
export PATH=$HOME/Applications/xtensa-lx106-elf/bin:$PATH
58
	export PATH=$HOME/Applications/xtensa-lx106-elf/bin:$PATH
57
  
59
  
58
# History and search. Stolen from J.
60
	# History and search. Stolen from J.
59
HISTCONTROL=ignoreboth
61
	HISTCONTROL=ignoreboth
60
shopt -s histappend
62
	shopt -s histappend
61
export HISTSIZE=
63
	export HISTSIZE=
62
export HISTFILESIZE=
64
	export HISTFILESIZE=
63
export HISTFILE=~/.bash_history_infinite
65
	export HISTFILE=~/.bash_history_infinite
64
PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
66
	PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
65
bind '"\e[A": history-search-backward'
67
	bind '"\e[A": history-search-backward'
66
bind '"\e[B": history-search-forward'
68
	bind '"\e[B": history-search-forward'
67
export HSTR_CONFIG=hicolor
69
	export HSTR_CONFIG=hicolor
68
if [[ $- =~ .i. ]]; then bind '"\C-h": "\C-a hstr -- \C-j"'; fi
70
	if [[ $- =~ .i. ]]; then bind '"\C-h": "\C-a hstr -- \C-j"'; fi
  
71
fi
69
  
72
  
70
# Backup to NAS function. Much wow!
73
# Backup to NAS function. Much wow!
71
backup() {
74
backup() {
...
105
	cd $CWD
108
	cd $CWD
106
}
109
}
107
  
110
  
  
111
# Toggles between pulseaudio sinks in round-robin.
  
112
# Gnome shortcut: ptyxis -- bash -c 'source ~/.shenanigans.sh && togglesink'
  
113
togglesink() {
  
114
	sinks=($(pactl list short sinks | awk '{print $2}'))
  
115
	current_sink=$(pactl get-default-sink)
  
116
	current_index=-1
  
117
  
  
118
	for i in "${!sinks[@]}"; do
  
119
		if [[ "${sinks[$i]}" == "$current_sink" ]]; then
  
120
			current_index=$i
  
121
			break
  
122
		fi
  
123
	done
  
124
  
  
125
	if [[ $current_index -eq -1 ]]; then
  
126
		next_index=0
  
127
	else
  
128
		next_index=$(( (current_index + 1) % ${#sinks[@]} ))
  
129
	fi
  
130
  
  
131
	pactl set-default-sink "${sinks[$next_index]}"
  
132
	notify-send "Switched to sink: ${sinks[$next_index]}"
  
133
}
diff --git a/.togglesink.sh b/.togglesink.sh
1
#/usr/bin/env sh
  
2
  
  
3
sinks=($(pactl list short sinks | awk '{print $2}'))
  
4
current_sink=$(pactl get-default-sink)
  
5
current_index=-1
  
6
  
  
7
for i in "${!sinks[@]}"; do
  
8
	if [[ "${sinks[$i]}" == "$current_sink" ]]; then
  
9
		current_index=$i
  
10
		break
  
11
	fi
  
12
done
  
13
  
  
14
if [[ $current_index -eq -1 ]]; then
  
15
	next_index=0
  
16
else
  
17
	next_index=$(( (current_index + 1) % ${#sinks[@]} ))
  
18
fi
  
19
  
  
20
pactl set-default-sink "${sinks[$next_index]}"
  
21
notify-send "Switched to sink: ${sinks[$next_index]}"