Last active
April 24, 2022 23:08
-
-
Save NickKelly1/0e5f83b6fe851cebfe4629227833e22f to your computer and use it in GitHub Desktop.
Revisions
-
NickKelly1 renamed this gist
Apr 24, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
NickKelly1 revised this gist
Apr 24, 2022 . 1 changed file with 35 additions and 23 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,12 +25,21 @@ set -e set -u set -o pipefail CONF_FILEPATH=~/.tmux.conf echo echo "=======================================" echo "=== Initialising tmux configuration ===" echo "=== author: Nick Kelly ===" echo "=== created: 2022-04-24 ===" echo "=== updated: 2022-04-24 ===" echo "=======================================" echo echo "Tmux conf filepath: ${CONF_FILEPATH}" if [[ -f "${CONF_FILEPATH}" ]]; then echo "${CONF_FILEPATH} already exists" read -r -p "Append to the existing .tmux.conf file? [Y/n] " cont case ${cont} in [yY][eE][sS]|[yY]) @@ -52,31 +61,33 @@ fi PREFIX_DEFAULT="b" PREFIX= read -e -p "Tmux prefix: " -i "${PREFIX_DEFAULT}" PREFIX # lowercase PREFIX=${PREFIX,,} # lowercase PREFIX=${PREFIX,,} # first char PREFIX=${PREFIX:0:1} PREFIX=${PREFIX:-${PREFIX_DEFAULT}} PREFIX_SECTION="# prefix: ${PREFIX}" if [[ "${PREFIX}" != "${PREFIX_DEFAULT}" ]]; then PREFIX_SECTION=$(cat <<-EOF # change prefix from ${PREFIX_DEFAULT} to ${PREFIX} unbind C-${PREFIX_DEFAULT} bind-key C-${PREFIX} send-prefix set -g prefix C-${PREFIX} EOF ) fi # bash heredoc # append these lines into CONF_FILEPATH cat <<-EOF >> ${CONF_FILEPATH} ${ABOUT} # vi mode @@ -92,12 +103,13 @@ bind-key -T prefix l select-pane -R bind-key -T prefix h select-pane -L # resize panes with vi keys bind-key C-k resize-pane -U 5 bind-key C-j resize-pane -D 5 bind-key C-l resize-pane -R 5 bind-key C-h resize-pane -L 5 # https://www.tecmint.com/owerline-adds-powerful-statuslines-and-prompts-to-vim-and-bash/ set -g default-terminal "xterm-256color" EOF echo "Finished. See new configuration in ${CONF_FILEPATH}" -
NickKelly1 revised this gist
Apr 24, 2022 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,5 @@ #! /usr/bin/env bash # # tmux config script # @@ -19,8 +18,8 @@ ABOUT=$(cat <<EOF # 2. view prefixed keys (preceeded by leader eg C-b): # - tmux list-keys prefix # ABOUT="" set -e set -u -
NickKelly1 revised this gist
Apr 24, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #! /usr/bin/env bash ABOUT=$(cat <<EOF # # tmux config script # -
NickKelly1 revised this gist
Apr 24, 2022 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,9 +7,7 @@ ABOUT=$(cat << EOF # https://gist.github.com/NickKelly1/0e5f83b6fe851cebfe4629227833e22f # # usage: # $ curl -s https://gist.github.com/NickKelly1/0e5f83b6fe851cebfe4629227833e22f/raw | bash # # author: Nick Kelly # created: 2022-04-24 -
NickKelly1 revised this gist
Apr 24, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #! /usr/bin/env bash ABOUT=$(cat << EOF # # tmux config script # @@ -78,7 +78,7 @@ fi # bash heredoc # append these lines into CONF_FILENAME cat << EOF >> ${CONF_FILENAME} ${ABOUT} -
NickKelly1 revised this gist
Apr 24, 2022 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,9 @@ ABOUT=$(cat EOF << # https://gist.github.com/NickKelly1/0e5f83b6fe851cebfe4629227833e22f # # usage: # ```sh # $ curl -s https://gist.github.com/NickKelly1/0e5f83b6fe851cebfe4629227833e22f/raw | bash # ``` # # author: Nick Kelly # created: 2022-04-24 -
NickKelly1 revised this gist
Apr 24, 2022 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,11 @@ ABOUT=$(cat EOF << # # tmux config script # # https://gist.github.com/NickKelly1/0e5f83b6fe851cebfe4629227833e22f # # usage: # $ # # author: Nick Kelly # created: 2022-04-24 # updated: 2022-04-24 -
NickKelly1 created this gist
Apr 24, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,99 @@ #! /usr/bin/env bash ABOUT=$(cat EOF << # # tmux config script # # author: Nick Kelly # created: 2022-04-24 # updated: 2022-04-24 # # useful tmux commands: # 1. view root keys (keys without prefix): # - tmux list-keys root # 2. view prefixed keys (preceeded by leader eg C-b): # - tmux list-keys prefix # EOF ) set -e set -u set -o pipefail CONF_FILENAME=~/.tmux.conf echo "tmux conf filename: ${CONF_FILENAME}" if [[ -f "${CONF_FILENAME}" ]]; then echo "${CONF_FILENAME} already exists" read -r -p "Append to the existing .tmux.conf file? [Y/n] " cont case ${cont} in [yY][eE][sS]|[yY]) # allow continue ;; [nN][oO]|[nN]) echo "Exiting" exit 0 ;; *) echo "Invalid input..." exit 1 ;; esac fi # get the desired prefix PREFIX_DEFAULT="b" PREFIX= echo "Prefix (default: ${PREFIX_DEFAULT}):" read -s PREFIX echo # lowercase PREFIX=${PREFIX,,} # first char PREFIX=${PREFIX:0:1} PREFIX_SECTION="# prefix: ${PREFIX_DEFAULT}" if [[ "${PREFIX}" != "${PREFIX_DEFAULT}" ]]; then PREFIX_SECTION=$(cat << EOF # change prefix from ${PREFIX_DEFAULT} to ${PREFIX} unbind C-${PREFIX_DEFAULT} bind-key C-${PREFIX} send-prefix set -g prefix C-${PREFIX} EOF ) fi # bash heredoc # append these lines into CONF_FILENAME cat <<EOF >> ${CONF_FILENAME} ${ABOUT} # vi mode # https://sanctum.geek.nz/arabesque/vi-mode-in-tmux/ set-window-option -g mode-keys vi ${PREFIX_SECTION} # switch between panes with vi keys bind-key -T prefix k select-pane -U bind-key -T prefix j select-pane -D bind-key -T prefix l select-pane -R bind-key -T prefix h select-pane -L # resize panes with vi keys bind-key -T C-k resize-pane -U 5 bind-key -T C-j resize-pane -D 5 bind-key -T C-l resize-pane -R 5 bind-key -T C-h resize-pane -L 5 # https://www.tecmint.com/owerline-adds-powerful-statuslines-and-prompts-to-vim-and-bash/ set -g default-terminal "xterm-256color" EOF