Merge branch 'tweaks' into 'main'

Some script tweaks + tmux shortcuts and theme

See merge request sagidayan/linux-config!14
This commit is contained in:
Sagi Dayan 2022-02-02 10:12:36 +00:00
commit 2254f0a109
8 changed files with 115 additions and 23 deletions

View file

@ -35,7 +35,7 @@ Run Workstation playbook on fedora:
Run cli-tools playbook on centos:
stage: x86 Systems
image:
name: centos:latest
name: quay.io/centos/centos:stream8
script:
- dnf install -y epel-release dnf-plugins-core
- dnf install -y --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-8.noarch.rpm

View file

@ -42,20 +42,21 @@ function gitB() {
if [ -d ./.git ]; then
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ $(git branch | wc -l) -lt 2 ]; then
echo "⚠️ Only ${CURRENT_BRANCH} exists."
echo "⚠️ Only ${CURRENT_BRANCH} exists."
return 1
fi
BRANCH=$(git branch -l |sed '/\*/d'| fzf --reverse --header="Current Branch: ${CURRENT_BRANCH}. Select Branch to checkout")
if [ -z ${BRANCH} ]; then
echo Canceled
echo Canceled
else
BRANCH=$(echo $BRANCH | xargs)
echo "Swiching to ${BRANCH}"
git ck "${BRANCH}"
fi
else
echo "[ERROR]: Not in a git repository"
echo " Not in a git repository"
fi;
echo "✅ Switched to ${BRANCH} branch successfully"
}
@ -109,7 +110,7 @@ function pre_check_tmux_for_layout() {
# $ ide name_for_workspace
function ide() {
CURRENT_DIR=$(echo "${PWD##*/}")
IDE_NAME="[⌨️ IDE: ${1:=$CURRENT_DIR}]"
IDE_NAME="${1:=$CURRENT_DIR}"
pre_check_tmux_for_layout "ide" || return 1
clear;
@ -131,7 +132,7 @@ function ide() {
function layout() {
pre_check_tmux_for_layout "layout/grid" || return 1
CURRENT_DIR=$(echo "${PWD##*/}")
LAYOUT_NAME="[#⃣ Layout: ${2:=$CURRENT_DIR}]"
LAYOUT_NAME="${2:=$CURRENT_DIR}"
INPUT=${1-}
if [ -z $INPUT ]; then
echo "Error: Invalid layout. Usage: $ layout <layout>"

View file

@ -27,7 +27,7 @@ if [ ! -z "$EXISTING_WSP" ]; then
fi
if [ -z "$NAME" ]; then
read -p "🖥 Please give this workspace a name: " NAME
read -p " Please give this workspace a name: " NAME
fi
if [ -z "$NAME" ]; then
@ -46,18 +46,28 @@ fi
CURRENT_DIR=$(pwd)
LAYOUT=$(cat <<EOF | fzf --reverse --header "Select a layout for ${NAME}"
LAYOUT=$(cat <<EOF | fzf --reverse --header " Select a layout/custom-command for ${NAME}"
ide
grid
layout "2 1"
layout "1 2"
Custom command
EOF
)
# If custom command...
IS_CMD=0
if [[ "${LAYOUT}" == "Custom command" ]]; then
IS_CMD=1
read -p " Please provide a command: " LAYOUT
fi
if [ -z "$LAYOUT" ]; then
echo "Invalid layout"
echo "Invalid layout/command"
exit 1
fi
echo $(cat ${JSON_PATH} \
| jq --arg NAME "$NAME" --arg LAYOUT "$LAYOUT" --arg CURRENT_DIR "$CURRENT_DIR" '. + {($NAME):{layout: $LAYOUT, dir: $CURRENT_DIR}}') > ${JSON_PATH}
| jq --arg NAME "$NAME" --arg LAYOUT "$LAYOUT" --arg CURRENT_DIR "$CURRENT_DIR" --arg IS_CMD "$IS_CMD" '. + {($NAME):{layout: $LAYOUT, dir: $CURRENT_DIR, is_cmd: $IS_CMD}}') > ${JSON_PATH}
echo "✅ Added ${NAME}"

View file

@ -7,7 +7,7 @@ WSP=$(cat ${JSON_PATH} \
| fzf --reverse --header "Select a Project to open"
)
if [ -z $WSP ]; then
if [ -z "$WSP" ]; then
echo "Aborted"
exit 1
fi
@ -20,15 +20,20 @@ LAYOUT=$(cat ${JSON_PATH} \
| jq -r --arg WSP "${WSP}" '.[$WSP]|.["layout"]' \
| tr -d '\r'
)
IS_CMD=$(cat ${JSON_PATH} \
| jq -r --arg WSP "${WSP}" '.[$WSP]|.["is_cmd"] // 0'
)
cd "$DIR"
LAYOUT_ARGS=$(echo $LAYOUT | grep -oP "(?<=layout ).*(?)")
echo $LAYOUT_ARGS
tmux neww
if [ ! -z $IS_LAYOUT ]; then
tmux send-keys "layout '${LAYOUT_ARGS}' '${WPS}'"
if [ $IS_CMD -eq 1 ]; then
tmux send-keys "${LAYOUT}" C-m
tmux rename-window "${WSP}"
elif [ ! -z $IS_LAYOUT ]; then
tmux send-keys "layout '${LAYOUT_ARGS}' '${WSP}'"
else
tmux send-keys "${LAYOUT} '${WSP}'" C-m
fi

View file

@ -2,7 +2,10 @@
set-option -g prefix C-a
unbind-key C-a
bind-key C-a send-prefix
# For gapless window numbers
set-option -g renumber-windows on
# Use Alt+[hjkl] to switch panes - also (esc - h|j|k|l)
bind -n M-h select-pane -L
bind -n M-l select-pane -R
@ -35,32 +38,41 @@ bind-key j send-keys Down
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded."
# Lookup the cheat sheet <prefix>-i
bind-key i run-shell "tmux neww -n '🏳️ CHEATER\! 😎' ~/.shellconfig/cheat.sh"
bind-key i run-shell "tmux neww -n '🏳️ CHEATER\! 😎' ~/.shellconfig/cheat.sh"
# Open Workspace
bind-key o run-shell "tmux neww -n '🖥Workspace Manager' ~/.shellconfig/workspaces/open_workspace.sh"
bind-key o run-shell "tmux neww -n '🖥 Workspace Manager' ~/.shellconfig/workspaces/open_workspace.sh"
# Add/Save Workspace
bind-key a run-shell "tmux neww -n '🖥Workspace Manager' 'cd #{pane_current_path} && ~/.shellconfig/workspaces/add_workspace.sh'"
bind-key a run-shell "tmux neww -n '🖥 Workspace Manager' 'cd #{pane_current_path} && ~/.shellconfig/workspaces/add_workspace.sh'"
# Delete (x) Workspace
bind-key x run-shell "tmux neww -n '🖥Workspace Manager' ~/.shellconfig/workspaces/delete_workspace.sh"
bind-key x run-shell "tmux neww -n '🖥 Workspace Manager' ~/.shellconfig/workspaces/delete_workspace.sh"
# Change git branches fast <prefix>-b
bind-key b send-keys "gitB" C-m
#bind-key b send-keys "gitB" C-m
bind-key b run-shell "tmux neww -n ' Git Branches' 'cd #{pane_current_path} && (zsh -c \"source ~/.shellconfig/common.sh && gitB\" || sleep 1)' "
# Git add + fzf
bind-key g run-shell "tmux neww -n '🞥 📑 Git Add' 'cd #{pane_current_path} && (git ls-files -m -o --exclude-standard | fzf -m --print0 --reverse --header \"🞥 Select files to stage. use [tab] for multi selection\" --preview \"bat --diff --color=always --style=numbers,changes,grid {}\" | xargs -0 -o -t git add)'"
bind-key g run-shell "tmux neww -n ' 🞥 Git Add' 'cd #{pane_current_path} && (git ls-files -m -o --exclude-standard | fzf -m --print0 --reverse --header \"🞥 Select files to stage. use [tab] for multi selection\" --preview \"bat --diff --color=always --style=numbers,changes,grid {}\" | xargs -0 -o -t git add)'"
# Get weather (Prefix-!)
bind-key \! run-shell "tmux neww -n '🌡️ Weather Peek' '(echo \"Fetching Weather...\" && curl -s \"https://wttr.in/?lang=en\") | bat --paging always -p'"
############################
# Themes
###########################
# Nord theme
set -g @plugin "arcticicestudio/nord-tmux"
# set -g @plugin "arcticicestudio/nord-tmux"
# Gruvbox Theme
# set -g @plugin 'egel/tmux-gruvbox'
# set -g @tmux-gruvbox 'dark' # or 'light'
############################
# Plugins
###########################
# Open links from output
set -g @plugin 'tmux-plugins/tmux-open'
# Tmux yank (For clipboard integration)
set -g @plugin 'tmux-plugins/tmux-yank'
# Mouse select to clipboard
@ -83,5 +95,66 @@ bind -n End send-key C-e
bind -n Home send-key C-a
# Set active pane border background
set-option -g pane-active-border-style bg=#8abeb7
#set-option -g pane-active-border-style bg=#8abeb7
############################
# Tomorrow-Night Theme
###########################
## set status bar
set -g status-style bg=default
setw -g window-status-current-style bg="#282a2e"
setw -g window-status-current-style fg="#81a2be"
## highlight active window
setw -g window-style 'bg=#282a2e'
setw -g window-active-style 'bg=#1d1f21'
setw -g pane-active-border-style ''
## highlight activity in status bar
setw -g window-status-activity-style fg="#8abeb7"
setw -g window-status-activity-style bg="#1d1f21"
## pane border and colors
set -g pane-active-border-style bg=default
set -g pane-active-border-style fg="#373b41"
set -g pane-border-style bg=default
set -g pane-border-style fg="#373b41"
set -g clock-mode-colour "#81a2be"
set -g clock-mode-style 24
set -g message-style bg="#8abeb7"
set -g message-style fg="#000000"
set -g message-command-style bg="#8abeb7"
set -g message-command-style fg="#000000"
# message bar or "prompt"
set -g message-style bg="#2d2d2d"
set -g message-style fg="#cc99cc"
set -g mode-style bg="#1d1f21"
set -g mode-style fg="#de935f"
set -g status-left '#[fg=#f99157,bg=#2d2d2d]  #S #[fg=#f99157,bg=colour235] '
# right side of status bar holds "[host name] (date time)"
set -g status-right-length 100
set -g status-right-style fg=black
set -g status-right-style bold
set -g status-right '#[fg=#6699cc,bg=#2d4d2d]  #[fg=#f99157,bg=#2d2d2d] %H:%M:%S #[fg=colour235]|#[fg=#6699cc,bg=#2d4d2d] #[fg=#f99157,bg=#2d2d2d] %y/%m/%d #[fg=colour235]|#[fg=#6699cc,bg=#2d4d2d] #[fg=#f99157,bg=#2d2d2d] @#H '
# make background window look like white tab
set-window-option -g window-status-style bg=default
set-window-option -g window-status-style fg=white
set-window-option -g window-status-style none
set-window-option -g window-status-format '#[fg=#6699cc,bg=#2d4d2d] #I #[fg=#999999,bg=#2d2d2d] #W #[default]'
# make foreground window look like bold yellow foreground tab
set-window-option -g window-status-current-style none
set-window-option -g window-status-current-format '#[fg=#f99157]#[fg=#6699cc]#I #[fg=#ffffff,bg=#6699cc] #W #[default]'
# active terminal yellow border, non-active white
set -g pane-border-style bg=default
set -g pane-border-style fg="#999999"
set -g pane-active-border-style fg="#f99157"

View file

@ -1,4 +1,5 @@
- hosts: localhost
name: CLI tools Playbook
vars:
# Theme options: monokai, gruvbox, nord, tomorrow-night
theme: tomorrow-night

View file

@ -1,4 +1,5 @@
- hosts: localhost
name: Self managed modern UNIX tools
vars:
# Theme options: monokai, gruvbox, nord, tomorrow-night
theme: tomorrow-night

View file

@ -1,4 +1,5 @@
- hosts: localhost
name: Workstation Playbook
vars:
# Theme options: monokai, gruvbox, nord, tomorrow-night
theme: tomorrow-night