From 5962fcf05a2af92d5fc2e0990836a3af0e7fbdd3 Mon Sep 17 00:00:00 2001 From: Mitchell Riedstra Date: Sat, 27 Jan 2024 10:30:19 -0500 Subject: Fix minor bugs. Sort Fedora packages. Add btop --- distro/fedora.sh | 13 ++++---- dotfiles/tmux.conf | 89 +++++++++++++++++++++++++++++++++++++++++++++++++ dotfiles/tmux_helper.sh | 28 ++++++++++++++++ dotfiles/tmx.sh | 55 ++++++++++++++++++++++++++++++ install.sh | 4 ++- tmux/tmux.conf | 89 ------------------------------------------------- tmux/tmux_helper.sh | 28 ---------------- tmux/tmx.sh | 55 ------------------------------ 8 files changed, 182 insertions(+), 179 deletions(-) create mode 100644 dotfiles/tmux.conf create mode 100644 dotfiles/tmux_helper.sh create mode 100644 dotfiles/tmx.sh delete mode 100644 tmux/tmux.conf delete mode 100644 tmux/tmux_helper.sh delete mode 100644 tmux/tmx.sh diff --git a/distro/fedora.sh b/distro/fedora.sh index a27e87d..cd809eb 100644 --- a/distro/fedora.sh +++ b/distro/fedora.sh @@ -4,13 +4,12 @@ yum -y group install "Development Tools" yum -y group install "C Development Tools and Libraries" yum -y builddep dmenu slock st yum -y install \ - NetworkManager-tui \ - ShellCheck \ ansible \ arandr \ bear \ bind-utils \ bsdtar \ + btop \ buildah \ chromium \ dunst \ @@ -30,21 +29,22 @@ yum -y install \ google-noto-emoji-fonts \ htop \ iperf3 \ - java-1.8.0-openjdk \ - java-1.8.0-openjdk-devel \ java-11-openjdk \ java-11-openjdk-devel \ + java-1.8.0-openjdk \ + java-1.8.0-openjdk-devel \ kpartx \ - libXt-devel \ libfido2 \ libvirt \ + libXt-devel \ lm_sensors \ maven \ ncdu \ ncmpc \ neofetch \ neovim \ - nload + NetworkManager-tui \ + nload \ npm \ oksh \ oksh \ @@ -62,6 +62,7 @@ yum -y install \ rlwrap \ rsync \ scrot \ + ShellCheck \ slock \ sxiv \ tmux \ diff --git a/dotfiles/tmux.conf b/dotfiles/tmux.conf new file mode 100644 index 0000000..a47df0b --- /dev/null +++ b/dotfiles/tmux.conf @@ -0,0 +1,89 @@ +set -g status-style "fg=green,bg=black" +set-window-option -g window-status-current-style "bg=green,fg=black" +set -g status-right "#[fg=black,bg=green] #(whoami)@#h|m:#(sh $HOME/.tmux_helper.sh memory)|l:#(sh $HOME/.tmux_helper.sh load)|#(sh $HOME/.tmux_helper.sh uptime)" +# For a basic tmux configuration without the helper +# set -g status-right "#[fg=black,bg=green] #(whoami)@#h" + +set -g status-position bottom +# Despite my preference for vi bindings elsewhere +set -g status-keys emacs + +# If you mark a pane with c-b m you can swap it tapping this +bind -N "Swap with marked pane" M-S swap-pane +bind -N "Swap with marked pane" '`' swap-pane + +# Pretty nifty little option to mirror input for all panes +bind -N "Syncronize input between panes" M-s set synchronize-panes + +# Allow the hotkeys to be switched using M-x to C-x, M-b to C-b, and so forth +bind -N "Change prefix" M-x set prefix C-x +bind -N "Change prefix" M-b set prefix C-b +bind -N "Change prefix" M-a set prefix C-a + +bind -N "Resize pane to 35% width" '|' resizep -x 35% +bind -N "Resize pane to 35% height" '\' resizep -y 35% +bind -N "Resize pane to 35% with and height, but prompt first" \ + '+' command-prompt -I "resizep -x 35% -y 35%" + +set -g mode-keys vi +# set -g aggressive-resize on + +# This has previously not given me any issues other than 'set termguicolors' in +# vim +# set -g default-terminal "screen-256color" + +# This seems to fix that problem, it may cause other issues but I'm going to +# keep an eye on it +# set-option -g default-terminal "tmux-256color" +set-option -g default-terminal "screen-256color" +set-option -ga terminal-overrides ",xterm*:Tc" + + +# Don't let command rename our windows +set-option -g allow-rename off + +# Press v to "visually" and y to "yank" the text +# Press `c-b ]` to paste +# If you ever want to look up a keybind use `c-b ?` +bind-key -T copy-mode-vi v send-keys -X begin-selection +bind-key -T copy-mode-vi y send-keys -X copy-selection + +# This one is also useful if you don't want to do what is listed above +# bind p paste-buffer + +# Rather large histroy buffer so I don't lose shit +set-option -g history-limit 16000 + +# Fix for certian applications such as Nvim +set -sg escape-time 0 + +# Select panes with vim like bindings +bind-key -N "Select pane above" M-k select-pane -U +bind-key -N "Select pane below" M-j select-pane -D +bind-key -N "Select pane to the left" M-h select-pane -L +bind-key -N "Select pane to the right" M-l select-pane -R + + +# Reload configuration +bind-key r source ~/.tmux.conf +# Respawn the pane # Useful if you have `set -g remain-on-exit on` or so +bind-key -N "Respawn pane" M-r respawn-pane + +# Change the status line a little bit, most are close to defaults +set -g status-left-length 35 +set -g status-left "[#S] " + +set -g status-right-length 40 +set -g window-status-format "#I:#W#F" + +set -g set-titles on +set -g set-titles-string "tmux: #{session_name} [#I]#{window_name} -- #T" + + +# If you still want to select text out of the terminal as you normally would +# You should hold the shift key ( Linux ) Option/Alt works in iTerm2 on MacOS +# Does not seem to work with the native terminal. +set -g mouse on + +# If you want any local configuration +source ~/.tmux.conf.local diff --git a/dotfiles/tmux_helper.sh b/dotfiles/tmux_helper.sh new file mode 100644 index 0000000..7ce68bd --- /dev/null +++ b/dotfiles/tmux_helper.sh @@ -0,0 +1,28 @@ +#!/bin/sh + + +# Little helper script to clean up the nasty embeded commands in my tmux configuration +# Functions ripped out of `mkshrc`, worth checking out + +_sys_memory() { + if [ `uname` = "Linux" ] ; then + vmstat | tail -n1 | awk '{print $4/1024}' | sed -e's/\..*$//g' + elif [ `uname` = "FreeBSD" ] ; then + vmstat | tail -n1 | awk '{print $5/1024}' | sed -e's/\..*$//g' + elif [ `uname` = "OpenBSD" ] ; then + vmstat | sed -n '$p' | awk '{print $4}' | sed 's/M$//' + fi +} + +_sys_load() { + # Works on BSD too, neat. + uptime | sed -re's/^.*load averages?: ([0-9]+\.[0-9]+).*$/\1/g' +} + +_sys_uptime() { + # Took awhile to figure out, but this works on BSD as well + uptime | sed -re's/^.*up[ ]+//g' -e's/^([^,]*),.*/\1/g' -e's/^([^ ]+)[ ]*(.).*/\1\2/g' +} + + +_sys_$1 diff --git a/dotfiles/tmx.sh b/dotfiles/tmx.sh new file mode 100644 index 0000000..0d66c27 --- /dev/null +++ b/dotfiles/tmx.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +# Modified further by Mitchell Riedstra to be compatible with /bin/sh + +# +# Modified TMUX start script from: +# http://forums.gentoo.org/viewtopic-t-836006-start-0.html +# +# Store it to `~/bin/tmx` and issue `chmod +x`. +# + +# Works because bash automatically trims by assigning to variables and by +# passing arguments +trim() { echo $1; } + +if [ -z "$1" ]; then + echo "Specify session name as the first argument" + exit +fi + +# Only because I often issue `ls` to this script by accident +if [ "$1" == "ls" ]; then + tmux ls + exit +fi + +base_session="$1" +# This actually works without the trim() on all systems except OSX +tmux_nb=$(trim `tmux ls | grep "^$base_session" | wc -l`) +if [ "$tmux_nb" == "0" ]; then + echo "Launching tmux base session $base_session ..." + tmux new-session -s $base_session +else + # Make sure we are not already in a tmux session + if [ -z "$TMUX" ]; then + # Kill defunct sessions first + old_sessions=$(tmux ls 2>/dev/null | egrep "^[0-9]{14}.*[0-9]+\)$" | cut -f 1 -d:) + for old_session_id in $old_sessions; do + tmux kill-session -t $old_session_id + done + + echo "Launching copy of base session $base_session ..." + # Session is is date and time to prevent conflict + session_id=`date +%Y%m%d%H%M%S` + # Create a new session (without attaching it) and link to base session + # to share windows + tmux new-session -d -t $base_session -s $session_id + # Create a new window in that session + #tmux new-window + # Attach to the new session + tmux attach-session -t $session_id + # When we detach from it, kill the session + tmux kill-session -t $session_id + fi +fi diff --git a/install.sh b/install.sh index e4d5b64..179a8d5 100755 --- a/install.sh +++ b/install.sh @@ -15,7 +15,9 @@ setLink() { return fi - [ -e "$dest" ] && rm "$dest" + if [ -L "$dest" ] || [ -e "$dest" ] ; then + rm "$dest" + fi ln -s "$src" "$dest" } diff --git a/tmux/tmux.conf b/tmux/tmux.conf deleted file mode 100644 index a47df0b..0000000 --- a/tmux/tmux.conf +++ /dev/null @@ -1,89 +0,0 @@ -set -g status-style "fg=green,bg=black" -set-window-option -g window-status-current-style "bg=green,fg=black" -set -g status-right "#[fg=black,bg=green] #(whoami)@#h|m:#(sh $HOME/.tmux_helper.sh memory)|l:#(sh $HOME/.tmux_helper.sh load)|#(sh $HOME/.tmux_helper.sh uptime)" -# For a basic tmux configuration without the helper -# set -g status-right "#[fg=black,bg=green] #(whoami)@#h" - -set -g status-position bottom -# Despite my preference for vi bindings elsewhere -set -g status-keys emacs - -# If you mark a pane with c-b m you can swap it tapping this -bind -N "Swap with marked pane" M-S swap-pane -bind -N "Swap with marked pane" '`' swap-pane - -# Pretty nifty little option to mirror input for all panes -bind -N "Syncronize input between panes" M-s set synchronize-panes - -# Allow the hotkeys to be switched using M-x to C-x, M-b to C-b, and so forth -bind -N "Change prefix" M-x set prefix C-x -bind -N "Change prefix" M-b set prefix C-b -bind -N "Change prefix" M-a set prefix C-a - -bind -N "Resize pane to 35% width" '|' resizep -x 35% -bind -N "Resize pane to 35% height" '\' resizep -y 35% -bind -N "Resize pane to 35% with and height, but prompt first" \ - '+' command-prompt -I "resizep -x 35% -y 35%" - -set -g mode-keys vi -# set -g aggressive-resize on - -# This has previously not given me any issues other than 'set termguicolors' in -# vim -# set -g default-terminal "screen-256color" - -# This seems to fix that problem, it may cause other issues but I'm going to -# keep an eye on it -# set-option -g default-terminal "tmux-256color" -set-option -g default-terminal "screen-256color" -set-option -ga terminal-overrides ",xterm*:Tc" - - -# Don't let command rename our windows -set-option -g allow-rename off - -# Press v to "visually" and y to "yank" the text -# Press `c-b ]` to paste -# If you ever want to look up a keybind use `c-b ?` -bind-key -T copy-mode-vi v send-keys -X begin-selection -bind-key -T copy-mode-vi y send-keys -X copy-selection - -# This one is also useful if you don't want to do what is listed above -# bind p paste-buffer - -# Rather large histroy buffer so I don't lose shit -set-option -g history-limit 16000 - -# Fix for certian applications such as Nvim -set -sg escape-time 0 - -# Select panes with vim like bindings -bind-key -N "Select pane above" M-k select-pane -U -bind-key -N "Select pane below" M-j select-pane -D -bind-key -N "Select pane to the left" M-h select-pane -L -bind-key -N "Select pane to the right" M-l select-pane -R - - -# Reload configuration -bind-key r source ~/.tmux.conf -# Respawn the pane # Useful if you have `set -g remain-on-exit on` or so -bind-key -N "Respawn pane" M-r respawn-pane - -# Change the status line a little bit, most are close to defaults -set -g status-left-length 35 -set -g status-left "[#S] " - -set -g status-right-length 40 -set -g window-status-format "#I:#W#F" - -set -g set-titles on -set -g set-titles-string "tmux: #{session_name} [#I]#{window_name} -- #T" - - -# If you still want to select text out of the terminal as you normally would -# You should hold the shift key ( Linux ) Option/Alt works in iTerm2 on MacOS -# Does not seem to work with the native terminal. -set -g mouse on - -# If you want any local configuration -source ~/.tmux.conf.local diff --git a/tmux/tmux_helper.sh b/tmux/tmux_helper.sh deleted file mode 100644 index 7ce68bd..0000000 --- a/tmux/tmux_helper.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - - -# Little helper script to clean up the nasty embeded commands in my tmux configuration -# Functions ripped out of `mkshrc`, worth checking out - -_sys_memory() { - if [ `uname` = "Linux" ] ; then - vmstat | tail -n1 | awk '{print $4/1024}' | sed -e's/\..*$//g' - elif [ `uname` = "FreeBSD" ] ; then - vmstat | tail -n1 | awk '{print $5/1024}' | sed -e's/\..*$//g' - elif [ `uname` = "OpenBSD" ] ; then - vmstat | sed -n '$p' | awk '{print $4}' | sed 's/M$//' - fi -} - -_sys_load() { - # Works on BSD too, neat. - uptime | sed -re's/^.*load averages?: ([0-9]+\.[0-9]+).*$/\1/g' -} - -_sys_uptime() { - # Took awhile to figure out, but this works on BSD as well - uptime | sed -re's/^.*up[ ]+//g' -e's/^([^,]*),.*/\1/g' -e's/^([^ ]+)[ ]*(.).*/\1\2/g' -} - - -_sys_$1 diff --git a/tmux/tmx.sh b/tmux/tmx.sh deleted file mode 100644 index 0d66c27..0000000 --- a/tmux/tmx.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh - -# Modified further by Mitchell Riedstra to be compatible with /bin/sh - -# -# Modified TMUX start script from: -# http://forums.gentoo.org/viewtopic-t-836006-start-0.html -# -# Store it to `~/bin/tmx` and issue `chmod +x`. -# - -# Works because bash automatically trims by assigning to variables and by -# passing arguments -trim() { echo $1; } - -if [ -z "$1" ]; then - echo "Specify session name as the first argument" - exit -fi - -# Only because I often issue `ls` to this script by accident -if [ "$1" == "ls" ]; then - tmux ls - exit -fi - -base_session="$1" -# This actually works without the trim() on all systems except OSX -tmux_nb=$(trim `tmux ls | grep "^$base_session" | wc -l`) -if [ "$tmux_nb" == "0" ]; then - echo "Launching tmux base session $base_session ..." - tmux new-session -s $base_session -else - # Make sure we are not already in a tmux session - if [ -z "$TMUX" ]; then - # Kill defunct sessions first - old_sessions=$(tmux ls 2>/dev/null | egrep "^[0-9]{14}.*[0-9]+\)$" | cut -f 1 -d:) - for old_session_id in $old_sessions; do - tmux kill-session -t $old_session_id - done - - echo "Launching copy of base session $base_session ..." - # Session is is date and time to prevent conflict - session_id=`date +%Y%m%d%H%M%S` - # Create a new session (without attaching it) and link to base session - # to share windows - tmux new-session -d -t $base_session -s $session_id - # Create a new window in that session - #tmux new-window - # Attach to the new session - tmux attach-session -t $session_id - # When we detach from it, kill the session - tmux kill-session -t $session_id - fi -fi -- cgit v1.2.3