aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2025-02-25 09:08:30 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2025-02-25 09:08:30 +0100
commitbb696a7fa6783e9d8bda8345fa4b7f5cb090e410 (patch)
tree1c53d3c49496bb40b6231f226e7d0652b27c3c52
parent47ac9cc92f1e5f748ecea7751c212231f1d5c8bb (diff)
downloaddotfiles-bb696a7fa6783e9d8bda8345fa4b7f5cb090e410.tar.gz
Update
-rwxr-xr-x.shenanigans.sh150
-rw-r--r--.togglesink.sh21
2 files changed, 88 insertions, 83 deletions
diff --git a/.shenanigans.sh b/.shenanigans.sh
index 5730ed6..1a213a9 100755
--- a/.shenanigans.sh
+++ b/.shenanigans.sh
@@ -4,68 +4,71 @@
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).
8export NIX_SHELL_PRESERVE_PROMPT=1 8if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
9export COLORTERM=truecolor 9 # Magical environment variables.
10export TERM=xterm-256color 10 export NIX_SHELL_PRESERVE_PROMPT=1
11export VISUAL=vim 11 export COLORTERM=truecolor
12export EDITOR=vim 12 export TERM=xterm-256color
13 13 export VISUAL=vim
14parse_git_branch() { 14 export EDITOR=vim
15 git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' 15
16} 16 parse_git_branch() {
17 17 git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
18is_inside_nix_shell() { 18 }
19 nix_shell_name="$(basename "$IN_NIX_SHELL" 2>/dev/null)" 19
20 if [[ -n "$nix_shell_name" ]]; then 20 is_inside_nix_shell() {
21 echo " \e[0;36m(nix-shell)\e[0m" 21 nix_shell_name="$(basename "$IN_NIX_SHELL" 2>/dev/null)"
22 fi 22 if [[ -n "$nix_shell_name" ]]; then
23} 23 echo " \e[0;36m(nix-shell)\e[0m"
24 24 fi
25# Better prompt. 25 }
26export 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$ " 26
27 27 # Better prompt.
28# General aliases. 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$ "
29alias l='ls -lh' 29
30alias ll='ls -lha' 30 # General aliases.
31alias t='tree -L 2' 31 alias l='ls -lh'
32alias ..='cd ..' 32 alias ll='ls -lha'
33alias grep='grep --color=always' 33 alias t='tree -L 2'
34alias less='less -R' 34 alias ..='cd ..'
35alias tmux='tmux -u' 35 alias grep='grep --color=always'
36alias vi='vim' 36 alias less='less -R'
37alias server='python3 -m http.server 6969' 37 alias tmux='tmux -u'
38alias gg='lazygit' 38 alias vi='vim'
39 39 alias server='python3 -m http.server 6969'
40# Custom folder jump commands. 40 alias gg='lazygit'
41alias p='cd ~/Vault/projects' 41
42alias j='cd ~/Junk/current' 42 # Custom folder jump commands.
43alias d='cd ~/Downloads' 43 alias p='cd ~/Vault/projects'
44 44 alias j='cd ~/Junk/current'
45# Additional path settings. 45 alias d='cd ~/Downloads'
46export PATH=$HOME/Applications:$PATH 46
47export PATH=$HOME/go/bin:$PATH 47 # Additional path settings.
48export PATH=$HOME/.local/bin:$PATH 48 export PATH=$HOME/Applications:$PATH
49export PATH=/usr/local/go/bin:$PATH 49 export PATH=$HOME/go/bin:$PATH
50 50 export PATH=$HOME/.local/bin:$PATH
51# Language servers. 51 export PATH=/usr/local/go/bin:$PATH
52export PATH=$HOME/.local/bin/luals/bin:$PATH 52
53 53 # Language servers.
54# Other stuff. 54 export PATH=$HOME/.local/bin/luals/bin:$PATH
55export PATH=$HOME/Applications/riscv-gnu-toolchain/bin:$PATH 55
56export PATH=$HOME/Applications/xtensa-lx106-elf/bin:$PATH 56 # Other stuff.
57 57 export PATH=$HOME/Applications/riscv-gnu-toolchain/bin:$PATH
58# History and search. Stolen from J. 58 export PATH=$HOME/Applications/xtensa-lx106-elf/bin:$PATH
59HISTCONTROL=ignoreboth 59
60shopt -s histappend 60 # History and search. Stolen from J.
61export HISTSIZE= 61 HISTCONTROL=ignoreboth
62export HISTFILESIZE= 62 shopt -s histappend
63export HISTFILE=~/.bash_history_infinite 63 export HISTSIZE=
64PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}" 64 export HISTFILESIZE=
65bind '"\e[A": history-search-backward' 65 export HISTFILE=~/.bash_history_infinite
66bind '"\e[B": history-search-forward' 66 PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
67export HSTR_CONFIG=hicolor 67 bind '"\e[A": history-search-backward'
68if [[ $- =~ .i. ]]; then bind '"\C-h": "\C-a hstr -- \C-j"'; fi 68 bind '"\e[B": history-search-forward'
69 export HSTR_CONFIG=hicolor
70 if [[ $- =~ .i. ]]; then bind '"\C-h": "\C-a hstr -- \C-j"'; fi
71fi
69 72
70# Backup to NAS function. Much wow! 73# Backup to NAS function. Much wow!
71backup() { 74backup() {
@@ -105,3 +108,26 @@ 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'
113togglesink() {
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
deleted file mode 100644
index eee44c6..0000000
--- a/.togglesink.sh
+++ /dev/null
@@ -1,21 +0,0 @@
1#/usr/bin/env sh
2
3sinks=($(pactl list short sinks | awk '{print $2}'))
4current_sink=$(pactl get-default-sink)
5current_index=-1
6
7for i in "${!sinks[@]}"; do
8 if [[ "${sinks[$i]}" == "$current_sink" ]]; then
9 current_index=$i
10 break
11 fi
12done
13
14if [[ $current_index -eq -1 ]]; then
15 next_index=0
16else
17 next_index=$(( (current_index + 1) % ${#sinks[@]} ))
18fi
19
20pactl set-default-sink "${sinks[$next_index]}"
21notify-send "Switched to sink: ${sinks[$next_index]}"