From b1b463addd4b2b864cf9278c85e1ea55fb588d9b Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Wed, 2 Feb 2022 10:13:19 +0200 Subject: [PATCH] Some script tweaks + tmux shortcuts and theme --- .gitlab-ci.yml | 2 +- files/dotfiles/shellconfig/common.sh | 11 ++- .../shellconfig/workspaces/add_workspace.sh | 18 +++- .../shellconfig/workspaces/open_workspace.sh | 13 ++- files/dotfiles/tmux.conf | 91 +++++++++++++++++-- playbooks/cli-tools.yml | 1 + playbooks/self-managed-unix-update.yml | 1 + playbooks/workstation.yml | 1 + 8 files changed, 115 insertions(+), 23 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5f5a81a..82a8ee0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/files/dotfiles/shellconfig/common.sh b/files/dotfiles/shellconfig/common.sh index 47953dc..657f66d 100644 --- a/files/dotfiles/shellconfig/common.sh +++ b/files/dotfiles/shellconfig/common.sh @@ -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 " diff --git a/files/dotfiles/shellconfig/workspaces/add_workspace.sh b/files/dotfiles/shellconfig/workspaces/add_workspace.sh index 335f5a0..1dd6e74 100755 --- a/files/dotfiles/shellconfig/workspaces/add_workspace.sh +++ b/files/dotfiles/shellconfig/workspaces/add_workspace.sh @@ -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 < ${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}" diff --git a/files/dotfiles/shellconfig/workspaces/open_workspace.sh b/files/dotfiles/shellconfig/workspaces/open_workspace.sh index a1d8fb9..ca6964e 100755 --- a/files/dotfiles/shellconfig/workspaces/open_workspace.sh +++ b/files/dotfiles/shellconfig/workspaces/open_workspace.sh @@ -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 diff --git a/files/dotfiles/tmux.conf b/files/dotfiles/tmux.conf index c5f9e75..ec09eb1 100644 --- a/files/dotfiles/tmux.conf +++ b/files/dotfiles/tmux.conf @@ -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 -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 -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" diff --git a/playbooks/cli-tools.yml b/playbooks/cli-tools.yml index d489c95..156d5dd 100644 --- a/playbooks/cli-tools.yml +++ b/playbooks/cli-tools.yml @@ -1,4 +1,5 @@ - hosts: localhost + name: CLI tools Playbook vars: # Theme options: monokai, gruvbox, nord, tomorrow-night theme: tomorrow-night diff --git a/playbooks/self-managed-unix-update.yml b/playbooks/self-managed-unix-update.yml index 9cb30b4..d2d097c 100644 --- a/playbooks/self-managed-unix-update.yml +++ b/playbooks/self-managed-unix-update.yml @@ -1,4 +1,5 @@ - hosts: localhost + name: Self managed modern UNIX tools vars: # Theme options: monokai, gruvbox, nord, tomorrow-night theme: tomorrow-night diff --git a/playbooks/workstation.yml b/playbooks/workstation.yml index 6c611d0..3cddde0 100644 --- a/playbooks/workstation.yml +++ b/playbooks/workstation.yml @@ -1,4 +1,5 @@ - hosts: localhost + name: Workstation Playbook vars: # Theme options: monokai, gruvbox, nord, tomorrow-night theme: tomorrow-night