From 8ec0ec3cef4e59c737a6ce3ca64e6e252aacd361 Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Sun, 28 Aug 2022 17:25:44 -0400 Subject: [PATCH] Set configs for different envrionments + Check if we're in docker or running xorg + Adjust tmux / vim settings --- .bash_aliases | 32 ++++++++++++++++++++++++------- .tmux.conf | 38 ++++++++++--------------------------- .tmux/.tmux-gui.conf | 20 ++++++++++++++++++++ .tmux/.tmux-tty.conf | 16 ++++++++++++++++ .tmux/tmux-conf.sh | 7 +++++++ .vimrc | 45 +++++++++++++++++++++++++++++++++++++------- README.md | 4 ++-- fix-vbox.sh | 5 ----- 8 files changed, 118 insertions(+), 49 deletions(-) create mode 100644 .tmux/.tmux-gui.conf create mode 100644 .tmux/.tmux-tty.conf create mode 100755 .tmux/tmux-conf.sh delete mode 100755 fix-vbox.sh diff --git a/.bash_aliases b/.bash_aliases index be7bf26..03db027 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -1,14 +1,23 @@ # For Rust stuff, uncomment this line #. "$HOME/.cargo/env" -# Clear kscreen cached settings -alias kapp-kscreen='rm -rf ~/.local/share/kscreen/*' -# Restart plasmashell -alias kapp-plasmashell='sudo pkill plasmashell && plasmashell --replace &> /dev/null &' -# Clear swap -alias kapp-swap='sudo swapoff -a && sudo swapon -a' alias kapp-git='git config --global user.name "Shaun Reed" && git config --global user.email "shaunrd0@gmail.com"' -alias kapp-update='sudo apt update -y && sudo apt upgrade -y && sudo apt upgrade --fix-broken --fix-missing --auto-remove' +if [ -f /.dockerenv ]; then + export DOT_PACKAGES='git stow vim tmux ranger clang wget curl' + alias kapp-update='apt update -y && apt upgrade -y && apt upgrade --fix-broken --fix-missing --auto-remove' + alias kapp-init='apt update -y && apt install $DOT_PACKAGES -y' + alias kapp-swap='swapoff -a && swapon -a' +else + export DOT_PACKAGES='git stow vim xsel xclip tmux ranger clang yakuake wget curl' + alias kapp-update='sudo apt update -y && sudo apt upgrade -y && sudo apt upgrade --fix-broken --fix-missing --auto-remove' + alias kapp-init='sudo apt update -y && sudo apt install $DOT_PACKAGES' + # Clear kscreen cached settings + alias kapp-kscreen='rm -rf ~/.local/share/kscreen/*' + # Restart plasmashell + alias kapp-plasmashell='sudo pkill plasmashell && plasmashell --replace &> /dev/null &' + alias kapp-swap='sudo swapoff -a && sudo swapon -a' + alias kapp-vbox='ps aux www |grep 'VBoxClient --draganddrop' | awk '{print $2}' | xargs kill' +fi # Alias / export customizations @@ -85,3 +94,12 @@ export LESS='--mouse --wheel-lines 2' # + -#2 to shift 2 columns horizontally when right / left arrow is pressed export LESS="$LESS -R -w -#2" + +if ! [ command -v conda &>/dev/null ] && [ -e ~/Code/Clones/mambaforge/bin/conda ] && ! grep -e conda ~/.bashrc &>/dev/null; then + if ! (~/Code/Clones/mambaforge/bin/conda init | awk -F "==>" '{print $1}'); then + echo "[dot] ERROR: Failed to initialize Conda." + fi + echo "[dot] WARN: Ran \`conda init\`; Conda was installed but not initialized" + source ~/.bashrc +fi + diff --git a/.tmux.conf b/.tmux.conf index 7c21d3a..d6d7230 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -57,9 +57,6 @@ bind -n M-Right select-pane -R bind -n M-Up select-pane -U bind -n M-Down select-pane -D -# Can't use theme plugin without risk of repo update overwriting data? -#source-file "${HOME}/.tmux-themepack/powerline/double/green.tmuxtheme" - set-option -g status-position top # Status update interval set -g status-interval 1 @@ -69,17 +66,15 @@ set -g status-style fg=colour240,bg=colour233 # Left side of status bar set -g status-left-style bg=colour233,fg=colour243 set -g status-left-length 40 + +# Note: Powerline font requires alternate of bold on right side +# + Corrects gap on right of character that reveals BG color # Note: No bold required, no BG reveal produced by symbol gaps on left side -#+ Font: Powerline Consolas -set -g status-left "#[fg=colour233,bg=colour100,bold] #S #[fg=colour100,bg=colour240,nobold]#[fg=colour233,bg=colour240] #(whoami) #[fg=colour240,bg=colour235]#[fg=colour240,bg=colour235] #(hostname) #[fg=colour235,bg=colour233]#[fg=colour240,bg=colour233]" +# + Font: Sauce Code Pro (NERD patch) # Right side of status bar set -g status-right-style bg=colour233,fg=colour243 set -g status-right-length 100 -# Note: Powerline font requires alternate of bold on right side -# Corrects gap on right of character that reveals BG color -#+ Font: Powerline Consolas -set -g status-right "#[fg=colour235,bg=colour233,bold]#[fg=colour240,bg=colour235,nobold] %H:%M:%S #[fg=colour240,bg=colour235,bold]#[fg=colour233,bg=colour240,nobold] %d-%b-%y #[fg=colour100,bg=colour240,bold]#[fg=colour233,bg=colour100,bold] #(cd #{pane_current_path}; basename `git rev-parse --show-toplevel`) " # Set gitmux to appear in center of tmux status bar run 'bash -c "if command -v $HOME/go/bin/gitmux &>/dev/null; then test -f $HOME/.gitmux.conf || $HOME/go/bin/gitmux -printcfg > $HOME/.gitmux.conf; fi"' @@ -87,6 +82,12 @@ set -g window-status-current-format "#($HOME/go/bin/gitmux -cfg $HOME/.gitmux.co # Or if you don't want gitmux #set -g window-status-current-format "#[fg=colour255,bg=colour233]#[fg=colour100,nobold] #(whoami)@#H #[fg=colour255,bg=colour233,nobold]" +run-shell "bash ~/.tmux/tmux-conf.sh" +# Check if we are running xorg +#set -g status-left "#[fg=colour233,bg=colour100,bold] #S #[fg=colour100,bg=colour240,nobold]#[fg=colour233,bg=colour240] #(whoami) #[fg=colour240,bg=colour235]#[fg=colour240,bg=colour235] #(hostname) #[fg=colour235,bg=colour233]#[fg=colour240,bg=colour233]" +#set -g status-right "#[fg=colour235,bg=colour233,bold]#[fg=colour240,bg=colour235,nobold] %H:%M:%S #[fg=colour240,bg=colour235,bold]#[fg=colour233,bg=colour240,nobold] %d-%b-%y #[fg=colour100,bg=colour240,bold]#[fg=colour233,bg=colour100,bold] #(cd #{pane_current_path}; basename `git rev-parse --show-toplevel`) " + + # Current window status set -g window-status-current-style bg=colour233,fg=colour100 # Window with activity status @@ -113,22 +114,3 @@ set -g default-terminal "screen-256color" # Mode set -g mode-style bg=colour100,fg=colour235 -# List of plugins and their settings -set -g @plugin 'tmux-plugins/tpm' -set -g @plugin 'nhdaly/tmux-better-mouse-mode' -set -g @scroll-speed-num-lines-per-scroll 2 -set -g @plugin 'tmux-plugins/tpm' -set -g @plugin 'tmux-plugins/tmux-yank' -set -g @yank_action 'copy-pipe-no-clear' -bind -T copy-mode C-c send -X copy-pipe-no-clear "xsel -i --clipboard" -bind -T copy-mode-vi C-c send -X copy-pipe-no-clear "xsel -i --clipboard" -#set -g @plugin 'tmux-plugins/tmux-sensible' -#set -g @plugin 'kristijanhusak/tmux-simple-git-status' -# Other examples: -# set -g @plugin 'github_username/plugin_name' -# set -g @plugin 'git@github.com/user/plugin' -# set -g @plugin 'git@bitbucket.com/user/plugin' - -# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) -run -b '~/.tmux/plugins/tpm/tpm' - diff --git a/.tmux/.tmux-gui.conf b/.tmux/.tmux-gui.conf new file mode 100644 index 0000000..f067462 --- /dev/null +++ b/.tmux/.tmux-gui.conf @@ -0,0 +1,20 @@ +set -g status-left "#[fg=colour233,bg=colour100,bold] #S #[fg=colour100,bg=colour240,nobold]#[fg=colour233,bg=colour240] #(whoami) #[fg=colour240,bg=colour235]#[fg=colour240,bg=colour235] #(hostname) #[fg=colour235,bg=colour233]#[fg=colour240,bg=colour233]" +set -g status-right "#[fg=colour235,bg=colour233,bold]#[fg=colour240,bg=colour235,nobold] %H:%M:%S #[fg=colour240,bg=colour235,bold]#[fg=colour233,bg=colour240,nobold] %d-%b-%y #[fg=colour100,bg=colour240,bold]#[fg=colour233,bg=colour100,bold] #(cd #{pane_current_path}; basename `git rev-parse --show-toplevel`) " + +# List of plugins and their settings +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'nhdaly/tmux-better-mouse-mode' +set -g @scroll-speed-num-lines-per-scroll 2 +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-yank' +set -g @yank_action 'copy-pipe-no-clear' +bind -T copy-mode C-c send -X copy-pipe-no-clear "xsel -i --clipboard" +bind -T copy-mode-vi C-c send -X copy-pipe-no-clear "xsel -i --clipboard" +# Other examples: +# set -g @plugin 'github_username/plugin_name' +# set -g @plugin 'git@github.com/user/plugin' +# set -g @plugin 'git@bitbucket.com/user/plugin' + +# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) +run -b '~/.tmux/plugins/tpm/tpm' + diff --git a/.tmux/.tmux-tty.conf b/.tmux/.tmux-tty.conf new file mode 100644 index 0000000..48a1029 --- /dev/null +++ b/.tmux/.tmux-tty.conf @@ -0,0 +1,16 @@ +set -g status-left "#[fg=colour233,bg=colour100,bold] #S #[fg=colour100,bg=colour240,nobold]#[fg=colour233,bg=colour240] #(whoami) #[fg=colour240,bg=colour235]#[fg=colour240,bg=colour235] #(hostname) #[fg=colour235,bg=colour233]#[fg=colour240,bg=colour233]" +set -g status-right "#[fg=colour235,bg=colour233,bold]#[fg=colour240,bg=colour235,nobold] %H:%M:%S #[fg=colour240,bg=colour235,bold]#[fg=colour233,bg=colour240,nobold] %d-%b-%y #[fg=colour100,bg=colour240,bold]#[fg=colour233,bg=colour100,bold] #(cd #{pane_current_path}; basename `git rev-parse --show-toplevel`) " + +# List of plugins and their settings +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'nhdaly/tmux-better-mouse-mode' +set -g @scroll-speed-num-lines-per-scroll 2 +set -g @plugin 'tmux-plugins/tpm' +# Other examples: +# set -g @plugin 'github_username/plugin_name' +# set -g @plugin 'git@github.com/user/plugin' +# set -g @plugin 'git@bitbucket.com/user/plugin' + +# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) +run -b '~/.tmux/plugins/tpm/tpm' + diff --git a/.tmux/tmux-conf.sh b/.tmux/tmux-conf.sh new file mode 100755 index 0000000..a5accb9 --- /dev/null +++ b/.tmux/tmux-conf.sh @@ -0,0 +1,7 @@ +#!/bin/bash +if [ -z ${DISPLAY+notset} ]; then + tmux source-file ~/.tmux/.tmux-tty.conf +else + tmux source-file ~/.tmux/.tmux-gui.conf +fi + diff --git a/.vimrc b/.vimrc index 490ee24..04e7251 100644 --- a/.vimrc +++ b/.vimrc @@ -2,6 +2,9 @@ " Double-quotes are commented out code and can be removed or added " General Vim Settings +let is_docker = filereadable(expand('/.dockerenv')) +let has_sauce = filereadable(expand('~/.local/share/fonts/sauce-code-pro.otf')) +let is_xorg = exists("$DISPLAY") " Highlight the column cursor is on " May slow screen redraw time, so off by default @@ -138,15 +141,13 @@ nnoremap :ColorToggle set termencoding=utf-8 set encoding=utf-8 -" air-line let g:airline_powerline_fonts = 1 - if !exists('g:airline_symbols') let g:airline_symbols = {} endif -if (exists("$SAUCE")) - " airline symbols +" Set glyphs based on font availability and environment (xorg / docker) +if and(and(has_sauce, is_xorg), !is_docker) let g:airline_left_sep = '' let g:airline_left_alt_sep = '' let g:airline_right_sep = '' @@ -154,20 +155,50 @@ if (exists("$SAUCE")) let g:airline_symbols.branch = '' let g:airline_symbols.readonly = '' let g:airline_symbols.linenr = '' -else +elseif is_xorg " unicode symbols let g:airline_left_sep = '»' let g:airline_left_sep = '▶' let g:airline_right_sep = '«' let g:airline_right_sep = '◀' - let g:airline_symbols.linenr = '␊' - let g:airline_symbols.linenr = '␤' + let g:airline_symbols.colnr = ' ㏇:' + let g:airline_symbols.colnr = ' ℅:' + let g:airline_symbols.crypt = '🔒' + let g:airline_symbols.linenr = '☰' + let g:airline_symbols.linenr = ' ␊:' + let g:airline_symbols.linenr = ' ␤:' let g:airline_symbols.linenr = '¶' + let g:airline_symbols.maxlinenr = '' + let g:airline_symbols.maxlinenr = '㏑' let g:airline_symbols.branch = '⎇' let g:airline_symbols.paste = 'ρ' let g:airline_symbols.paste = 'Þ' let g:airline_symbols.paste = '∥' + let g:airline_symbols.spell = 'Ꞩ' + let g:airline_symbols.notexists = 'Ɇ' let g:airline_symbols.whitespace = 'Ξ' +else + " unicode symbols + let g:airline_left_sep = '' + let g:airline_left_sep = '' + let g:airline_right_sep = '' + let g:airline_right_sep = '' + let g:airline_symbols.colnr = '' + let g:airline_symbols.colnr = '' + let g:airline_symbols.crypt = '' + let g:airline_symbols.linenr = '' + let g:airline_symbols.linenr = '' + let g:airline_symbols.linenr = '' + let g:airline_symbols.linenr = '' + let g:airline_symbols.maxlinenr = '' + let g:airline_symbols.maxlinenr = '' + let g:airline_symbols.branch = '' + let g:airline_symbols.paste = '' + let g:airline_symbols.paste = '' + let g:airline_symbols.paste = '' + let g:airline_symbols.spell = '' + let g:airline_symbols.notexists = '' + let g:airline_symbols.whitespace = '' endif " Clang completeion settings diff --git a/README.md b/README.md index 4d152cc..882a593 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Once installed, editing source code in vim supports features displayed in the sc Easiest installation is to clone repository into home directory - ```bash -sudo apt install vim xsel xclip tmux ranger clang yakuake +sudo apt install git stow vim xsel xclip tmux ranger clang yakuake wget curl git clone --recursive https://github.com/shaunrd0/dot ~/dot cd ~/dot/ stow --adopt . @@ -27,7 +27,7 @@ stow --adopt -t ~ . **Warning:** `--adopt` is used to link conflicting files, but doing so could result in the loss of some configs within your local copy of the repository and on your local system. After running `stow --adopt .`, be sure to check `git status` is clean. -If a file has been modified, discard the local changes to be up-to-date with `origin/master` and it will be restored on your system as well, since the files are now linked. +If a file has been modified, discard the local changes to be up-to-date with `origin/master` and it will be restored on your system as well, since the files are now linked. **Your conflicting local system configurations will be lost** unless you back them up manually. We could run the following commands to restore changed files ```bash diff --git a/fix-vbox.sh b/fix-vbox.sh deleted file mode 100755 index 832dd0c..0000000 --- a/fix-vbox.sh +++ /dev/null @@ -1,5 +0,0 @@ -# A fix for a common issue found in virtual box -# https://forums.linuxmint.com/viewtopic.php?t=247850 -# https://askubuntu.com/questions/1014172/virtualbox-unresponsive-area-on-desktop -################################################################################# -ps aux www |grep 'VBoxClient --draganddrop' | awk '{print $2}' | xargs kill