diff options
| 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) | |
| tree | 1c53d3c49496bb40b6231f226e7d0652b27c3c52 | |
| parent | 47ac9cc92f1e5f748ecea7751c212231f1d5c8bb (diff) | |
| download | dotfiles-bb696a7fa6783e9d8bda8345fa4b7f5cb090e410.tar.gz | |
Update
| -rwxr-xr-x | .shenanigans.sh | 150 | ||||
| -rw-r--r-- | .togglesink.sh | 21 |
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). |
| 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 | 13 | export VISUAL=vim | |
| 14 | parse_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)/' | |
| 18 | is_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 | } |
| 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$ " | 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$ " |
| 29 | alias l='ls -lh' | 29 | |
| 30 | alias ll='ls -lha' | 30 | # General aliases. |
| 31 | alias t='tree -L 2' | 31 | alias l='ls -lh' |
| 32 | alias ..='cd ..' | 32 | alias ll='ls -lha' |
| 33 | alias grep='grep --color=always' | 33 | alias t='tree -L 2' |
| 34 | alias less='less -R' | 34 | alias ..='cd ..' |
| 35 | alias tmux='tmux -u' | 35 | alias grep='grep --color=always' |
| 36 | alias vi='vim' | 36 | alias less='less -R' |
| 37 | alias server='python3 -m http.server 6969' | 37 | alias tmux='tmux -u' |
| 38 | alias gg='lazygit' | 38 | alias vi='vim' |
| 39 | 39 | alias server='python3 -m http.server 6969' | |
| 40 | # Custom folder jump commands. | 40 | alias gg='lazygit' |
| 41 | alias p='cd ~/Vault/projects' | 41 | |
| 42 | alias j='cd ~/Junk/current' | 42 | # Custom folder jump commands. |
| 43 | alias 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' |
| 46 | export PATH=$HOME/Applications:$PATH | 46 | |
| 47 | export PATH=$HOME/go/bin:$PATH | 47 | # Additional path settings. |
| 48 | export PATH=$HOME/.local/bin:$PATH | 48 | export PATH=$HOME/Applications:$PATH |
| 49 | export 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 |
| 52 | export PATH=$HOME/.local/bin/luals/bin:$PATH | 52 | |
| 53 | 53 | # Language servers. | |
| 54 | # Other stuff. | 54 | export PATH=$HOME/.local/bin/luals/bin:$PATH |
| 55 | export PATH=$HOME/Applications/riscv-gnu-toolchain/bin:$PATH | 55 | |
| 56 | export 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 |
| 59 | HISTCONTROL=ignoreboth | 59 | |
| 60 | shopt -s histappend | 60 | # History and search. Stolen from J. |
| 61 | export HISTSIZE= | 61 | HISTCONTROL=ignoreboth |
| 62 | export HISTFILESIZE= | 62 | shopt -s histappend |
| 63 | export HISTFILE=~/.bash_history_infinite | 63 | export HISTSIZE= |
| 64 | PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}" | 64 | export HISTFILESIZE= |
| 65 | bind '"\e[A": history-search-backward' | 65 | export HISTFILE=~/.bash_history_infinite |
| 66 | bind '"\e[B": history-search-forward' | 66 | PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}" |
| 67 | export HSTR_CONFIG=hicolor | 67 | bind '"\e[A": history-search-backward' |
| 68 | if [[ $- =~ .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 | ||
| 71 | fi | ||
| 69 | 72 | ||
| 70 | # Backup to NAS function. Much wow! | 73 | # Backup to NAS function. Much wow! |
| 71 | backup() { | 74 | backup() { |
| @@ -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' | ||
| 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 deleted file mode 100644 index eee44c6..0000000 --- a/.togglesink.sh +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 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]}" | ||
