diff options
Diffstat (limited to 'shenanigans.sh')
| -rwxr-xr-x | shenanigans.sh | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/shenanigans.sh b/shenanigans.sh new file mode 100755 index 0000000..040f8bc --- /dev/null +++ b/shenanigans.sh | |||
| @@ -0,0 +1,128 @@ | |||
| 1 | # Software list. | ||
| 2 | # cifs-utils tree jq xmlstarlet s3cmd xclip neovim mc gnupg | ||
| 3 | # tilix fzf ripgrep | ||
| 4 | |||
| 5 | # Magical environment variables. | ||
| 6 | |||
| 7 | NIX_SHELL_PRESERVE_PROMPT=1 | ||
| 8 | TERM=xterm-256color | ||
| 9 | EDITOR=vim | ||
| 10 | |||
| 11 | # Better prompt. | ||
| 12 | |||
| 13 | parse_git_branch() { | ||
| 14 | git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | ||
| 15 | } | ||
| 16 | |||
| 17 | is_inside_nix_shell() { | ||
| 18 | nix_shell_name="$(basename "$IN_NIX_SHELL" 2>/dev/null)" | ||
| 19 | if [[ -n "$nix_shell_name" ]]; then | ||
| 20 | echo " \e[0;36m(nix-shell)\e[0m" | ||
| 21 | fi | ||
| 22 | } | ||
| 23 | |||
| 24 | export PS1="[\033[38;5;9m\]\u@\h\[$(tput sgr0)\]]$(is_inside_nix_shell)\[\033[33m\]\$(parse_git_branch)\[\033[00m\] \w\[$(tput sgr0)\] \n$ " | ||
| 25 | |||
| 26 | # General aliases. | ||
| 27 | |||
| 28 | alias c='clear' | ||
| 29 | alias l='ls -lh' | ||
| 30 | alias ll='ls -lha' | ||
| 31 | alias t='tree -L 2' | ||
| 32 | alias ..='cd ..' | ||
| 33 | alias h='history' | ||
| 34 | alias x='exit' | ||
| 35 | alias grep='grep --color=always' | ||
| 36 | alias less='less -R' | ||
| 37 | alias e='emacs' | ||
| 38 | alias n='nvim' | ||
| 39 | alias gg='lazygit' | ||
| 40 | alias gt='git-town' | ||
| 41 | alias server='python3 -m http.server 6969' | ||
| 42 | |||
| 43 | # Custom folder jump commands. | ||
| 44 | |||
| 45 | alias p='cd ~/Vault/projects' | ||
| 46 | alias j='cd ~/Junk' | ||
| 47 | alias d='cd ~/Downloads' | ||
| 48 | alias v='cd ~/Vault' | ||
| 49 | |||
| 50 | # Additional path settings. | ||
| 51 | |||
| 52 | export PATH=$HOME/Vault/bin:$PATH | ||
| 53 | export PATH=$HOME/Applications:$PATH | ||
| 54 | export PATH=$HOME/.local/bin:$PATH | ||
| 55 | export PATH=$HOME/go/bin:$PATH | ||
| 56 | |||
| 57 | export PATH=$HOME/Android/Sdk/platform-tools:$PATH | ||
| 58 | export PATH=$HOME/Android/Sdk/tools:$PATH | ||
| 59 | |||
| 60 | # History and search. | ||
| 61 | |||
| 62 | HISTCONTROL=ignoreboth | ||
| 63 | shopt -s histappend | ||
| 64 | export HISTSIZE= | ||
| 65 | export HISTFILESIZE= | ||
| 66 | export HISTFILE=~/.bash_history_infinite | ||
| 67 | PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}" | ||
| 68 | bind '"\e[A": history-search-backward' | ||
| 69 | bind '"\e[B": history-search-forward' | ||
| 70 | alias hh=hstr | ||
| 71 | export HSTR_CONFIG=hicolor | ||
| 72 | if [[ $- =~ .i. ]]; then bind '"\C-h": "\C-a hstr -- \C-j"'; fi | ||
| 73 | |||
| 74 | # Useful function. Much wow! | ||
| 75 | |||
| 76 | backup() { | ||
| 77 | VHOME=/home/$USER/Vault | ||
| 78 | ME=$(whoami)@$(hostname) | ||
| 79 | |||
| 80 | mkdir -p $VHOME/dotfiles | ||
| 81 | cd $VHOME/dotfiles | ||
| 82 | |||
| 83 | # Make a copy of dotfiles. | ||
| 84 | cp /home/$USER/.shenanigans.sh shenanigans.sh | ||
| 85 | cp /home/$USER/.bash_history bash_history | ||
| 86 | cp /home/$USER/.bash_history_infinite bash_history_infinite | ||
| 87 | cp /home/$USER/.smbcredentials smbcredentials | ||
| 88 | cp /home/$USER/.gitconfig gitconfig | ||
| 89 | cp /home/$USER/.s3cfg s3cfg | ||
| 90 | |||
| 91 | cp /home/$USER/.vimrc vimrc | ||
| 92 | cp /home/$USER/.config/nvim/init.lua neovim.lua | ||
| 93 | cp /home/$USER/.config/emacs/init.el init.el | ||
| 94 | |||
| 95 | cp -Rf /home/$USER/.ssh/ ./ | ||
| 96 | cp -Rf /home/$USER/.aws/ ./ | ||
| 97 | |||
| 98 | dconf dump /com/gexperts/Tilix/ > tilix.dconf | ||
| 99 | # dconf load /com/gexperts/Tilix/ < tilix.dconf | ||
| 100 | |||
| 101 | # Backup screenshots. | ||
| 102 | mkdir -p $VHOME/pictures | ||
| 103 | cp -rfn ~/Pictures/* $VHOME/pictures/ | ||
| 104 | |||
| 105 | # Backup screencasts. | ||
| 106 | mkdir -p $VHOME/videos | ||
| 107 | cp -rfn ~/Videos/* $VHOME/videos/ | ||
| 108 | |||
| 109 | # Sync with NAS. | ||
| 110 | rsync -azv \ | ||
| 111 | --exclude '.venv/' \ | ||
| 112 | --exclude '.git/' \ | ||
| 113 | --exclude 'node_modules/' \ | ||
| 114 | --delete \ | ||
| 115 | $VHOME/ /media/Void/Backup/$ME/ | ||
| 116 | |||
| 117 | # Sync to off-site DO S3 bucket. | ||
| 118 | s3cmd sync \ | ||
| 119 | --host-bucket=vault \ | ||
| 120 | --delete-removed \ | ||
| 121 | --exclude 'node_modules/*' \ | ||
| 122 | --exclude '.git/*' \ | ||
| 123 | --exclude '.venv/*' \ | ||
| 124 | $VHOME/ s3://vault/backup/$ME/ | ||
| 125 | |||
| 126 | # Add to log file. | ||
| 127 | echo `date +"%D %T"` >> ~/.vault.log | ||
| 128 | } | ||
