mirror of
https://gitlab.com/sagidayan/linux-config.git
synced 2024-11-21 23:05:25 +00:00
Merge branch 'tweaks' into 'main'
Some script tweaks + tmux shortcuts and theme See merge request sagidayan/linux-config!14
This commit is contained in:
commit
2254f0a109
8 changed files with 115 additions and 23 deletions
|
@ -35,7 +35,7 @@ Run Workstation playbook on fedora:
|
||||||
Run cli-tools playbook on centos:
|
Run cli-tools playbook on centos:
|
||||||
stage: x86 Systems
|
stage: x86 Systems
|
||||||
image:
|
image:
|
||||||
name: centos:latest
|
name: quay.io/centos/centos:stream8
|
||||||
script:
|
script:
|
||||||
- dnf install -y epel-release dnf-plugins-core
|
- 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
|
- 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
|
||||||
|
|
|
@ -42,20 +42,21 @@ function gitB() {
|
||||||
if [ -d ./.git ]; then
|
if [ -d ./.git ]; then
|
||||||
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||||
if [ $(git branch | wc -l) -lt 2 ]; then
|
if [ $(git branch | wc -l) -lt 2 ]; then
|
||||||
echo "⚠️ Only ${CURRENT_BRANCH} exists."
|
echo "⚠️ Only ${CURRENT_BRANCH} exists."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
BRANCH=$(git branch -l |sed '/\*/d'| fzf --reverse --header="Current Branch: ${CURRENT_BRANCH}. Select Branch to checkout")
|
BRANCH=$(git branch -l |sed '/\*/d'| fzf --reverse --header="Current Branch: ${CURRENT_BRANCH}. Select Branch to checkout")
|
||||||
if [ -z ${BRANCH} ]; then
|
if [ -z ${BRANCH} ]; then
|
||||||
echo Canceled
|
echo ❌ Canceled
|
||||||
else
|
else
|
||||||
BRANCH=$(echo $BRANCH | xargs)
|
BRANCH=$(echo $BRANCH | xargs)
|
||||||
echo "Swiching to ${BRANCH}"
|
echo "Swiching to ${BRANCH}"
|
||||||
git ck "${BRANCH}"
|
git ck "${BRANCH}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "[ERROR]: Not in a git repository"
|
echo "❌ Not in a git repository"
|
||||||
fi;
|
fi;
|
||||||
|
echo "✅ Switched to ${BRANCH} branch successfully"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,7 +110,7 @@ function pre_check_tmux_for_layout() {
|
||||||
# $ ide name_for_workspace
|
# $ ide name_for_workspace
|
||||||
function ide() {
|
function ide() {
|
||||||
CURRENT_DIR=$(echo "${PWD##*/}")
|
CURRENT_DIR=$(echo "${PWD##*/}")
|
||||||
IDE_NAME="[⌨️ IDE: ${1:=$CURRENT_DIR}]"
|
IDE_NAME="${1:=$CURRENT_DIR}"
|
||||||
|
|
||||||
pre_check_tmux_for_layout "ide" || return 1
|
pre_check_tmux_for_layout "ide" || return 1
|
||||||
clear;
|
clear;
|
||||||
|
@ -131,7 +132,7 @@ function ide() {
|
||||||
function layout() {
|
function layout() {
|
||||||
pre_check_tmux_for_layout "layout/grid" || return 1
|
pre_check_tmux_for_layout "layout/grid" || return 1
|
||||||
CURRENT_DIR=$(echo "${PWD##*/}")
|
CURRENT_DIR=$(echo "${PWD##*/}")
|
||||||
LAYOUT_NAME="[#⃣ Layout: ${2:=$CURRENT_DIR}]"
|
LAYOUT_NAME="${2:=$CURRENT_DIR}"
|
||||||
INPUT=${1-}
|
INPUT=${1-}
|
||||||
if [ -z $INPUT ]; then
|
if [ -z $INPUT ]; then
|
||||||
echo "Error: Invalid layout. Usage: $ layout <layout>"
|
echo "Error: Invalid layout. Usage: $ layout <layout>"
|
||||||
|
|
|
@ -27,7 +27,7 @@ if [ ! -z "$EXISTING_WSP" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$NAME" ]; then
|
if [ -z "$NAME" ]; then
|
||||||
read -p "🖥 Please give this workspace a name: " NAME
|
read -p "ℹ️ Please give this workspace a name: " NAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$NAME" ]; then
|
if [ -z "$NAME" ]; then
|
||||||
|
@ -46,18 +46,28 @@ fi
|
||||||
|
|
||||||
CURRENT_DIR=$(pwd)
|
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
|
ide
|
||||||
grid
|
grid
|
||||||
layout "2 1"
|
layout "2 1"
|
||||||
layout "1 2"
|
layout "1 2"
|
||||||
|
Custom command
|
||||||
EOF
|
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
|
if [ -z "$LAYOUT" ]; then
|
||||||
echo "Invalid layout"
|
echo "Invalid layout/command"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $(cat ${JSON_PATH} \
|
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}"
|
echo "✅ Added ${NAME}"
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ WSP=$(cat ${JSON_PATH} \
|
||||||
| fzf --reverse --header "Select a Project to open"
|
| fzf --reverse --header "Select a Project to open"
|
||||||
)
|
)
|
||||||
|
|
||||||
if [ -z $WSP ]; then
|
if [ -z "$WSP" ]; then
|
||||||
echo "Aborted"
|
echo "Aborted"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -20,15 +20,20 @@ LAYOUT=$(cat ${JSON_PATH} \
|
||||||
| jq -r --arg WSP "${WSP}" '.[$WSP]|.["layout"]' \
|
| jq -r --arg WSP "${WSP}" '.[$WSP]|.["layout"]' \
|
||||||
| tr -d '\r'
|
| tr -d '\r'
|
||||||
)
|
)
|
||||||
|
IS_CMD=$(cat ${JSON_PATH} \
|
||||||
|
| jq -r --arg WSP "${WSP}" '.[$WSP]|.["is_cmd"] // 0'
|
||||||
|
)
|
||||||
cd "$DIR"
|
cd "$DIR"
|
||||||
|
|
||||||
LAYOUT_ARGS=$(echo $LAYOUT | grep -oP "(?<=layout ).*(?)")
|
LAYOUT_ARGS=$(echo $LAYOUT | grep -oP "(?<=layout ).*(?)")
|
||||||
echo $LAYOUT_ARGS
|
echo $LAYOUT_ARGS
|
||||||
|
|
||||||
tmux neww
|
tmux neww
|
||||||
if [ ! -z $IS_LAYOUT ]; then
|
if [ $IS_CMD -eq 1 ]; then
|
||||||
tmux send-keys "layout '${LAYOUT_ARGS}' '${WPS}'"
|
tmux send-keys "${LAYOUT}" C-m
|
||||||
|
tmux rename-window "${WSP}"
|
||||||
|
elif [ ! -z $IS_LAYOUT ]; then
|
||||||
|
tmux send-keys "layout '${LAYOUT_ARGS}' '${WSP}'"
|
||||||
else
|
else
|
||||||
tmux send-keys "${LAYOUT} '${WSP}'" C-m
|
tmux send-keys "${LAYOUT} '${WSP}'" C-m
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
set-option -g prefix C-a
|
set-option -g prefix C-a
|
||||||
unbind-key C-a
|
unbind-key C-a
|
||||||
bind-key C-a send-prefix
|
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)
|
# Use Alt+[hjkl] to switch panes - also (esc - h|j|k|l)
|
||||||
bind -n M-h select-pane -L
|
bind -n M-h select-pane -L
|
||||||
bind -n M-l select-pane -R
|
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."
|
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded."
|
||||||
|
|
||||||
# Lookup the cheat sheet <prefix>-i
|
# 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
|
# 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
|
# 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
|
# 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
|
# 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
|
# 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
|
# Themes
|
||||||
###########################
|
###########################
|
||||||
# Nord theme
|
# Nord theme
|
||||||
set -g @plugin "arcticicestudio/nord-tmux"
|
# set -g @plugin "arcticicestudio/nord-tmux"
|
||||||
# Gruvbox Theme
|
# Gruvbox Theme
|
||||||
# set -g @plugin 'egel/tmux-gruvbox'
|
# set -g @plugin 'egel/tmux-gruvbox'
|
||||||
# set -g @tmux-gruvbox 'dark' # or 'light'
|
# set -g @tmux-gruvbox 'dark' # or 'light'
|
||||||
|
|
||||||
|
############################
|
||||||
|
# Plugins
|
||||||
|
###########################
|
||||||
|
# Open links from output
|
||||||
|
set -g @plugin 'tmux-plugins/tmux-open'
|
||||||
# Tmux yank (For clipboard integration)
|
# Tmux yank (For clipboard integration)
|
||||||
set -g @plugin 'tmux-plugins/tmux-yank'
|
set -g @plugin 'tmux-plugins/tmux-yank'
|
||||||
# Mouse select to clipboard
|
# Mouse select to clipboard
|
||||||
|
@ -83,5 +95,66 @@ bind -n End send-key C-e
|
||||||
bind -n Home send-key C-a
|
bind -n Home send-key C-a
|
||||||
|
|
||||||
# Set active pane border background
|
# 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"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
|
name: CLI tools Playbook
|
||||||
vars:
|
vars:
|
||||||
# Theme options: monokai, gruvbox, nord, tomorrow-night
|
# Theme options: monokai, gruvbox, nord, tomorrow-night
|
||||||
theme: tomorrow-night
|
theme: tomorrow-night
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
|
name: Self managed modern UNIX tools
|
||||||
vars:
|
vars:
|
||||||
# Theme options: monokai, gruvbox, nord, tomorrow-night
|
# Theme options: monokai, gruvbox, nord, tomorrow-night
|
||||||
theme: tomorrow-night
|
theme: tomorrow-night
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
|
name: Workstation Playbook
|
||||||
vars:
|
vars:
|
||||||
# Theme options: monokai, gruvbox, nord, tomorrow-night
|
# Theme options: monokai, gruvbox, nord, tomorrow-night
|
||||||
theme: tomorrow-night
|
theme: tomorrow-night
|
||||||
|
|
Loading…
Reference in a new issue