From d8ab048b10653b993106f7436c1262ebb91acc9b Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Tue, 14 Nov 2023 15:35:10 +0000 Subject: [PATCH] tweak: start adding bash and tmux configurations. --- README.md | 27 ---------------- config/bash/shadows.sh | 17 ++++++++++ config/tmux/.tmux.conf | 70 +++++++++++++++++++++++++++++++++++++++++ packages/core/1-bash.sh | 1 + packages/core/2-tmux.sh | 1 + 5 files changed, 89 insertions(+), 27 deletions(-) create mode 100644 config/bash/shadows.sh create mode 100644 config/tmux/.tmux.conf create mode 100644 packages/core/1-bash.sh create mode 100644 packages/core/2-tmux.sh diff --git a/README.md b/README.md index 29cb18b..ea2eb4a 100644 --- a/README.md +++ b/README.md @@ -42,33 +42,6 @@ chmod +x bootstrap.sh bash bootstrap.sh ``` -## Preparatory steps - -### 1. Give sudo permissions to your user - -Give sudo permissions to your user: - -``` -``` - -### 2. Install git and download the rest of this distribution - -``` -sudo apt install git - -git config --global user.email "nuno.semperelh@protonmail.com" # to do: add part of a script that asks you for this, or lets you configure it -git config --global user.name "NunoSempere" -git config --global credential.helper 'store --file ~/.git-credentials' -git config --global init.defaultBranch master - -cd ~/Documents -git clone https://git.nunosempere.com/open.source/nunOS.git -``` - -N.B.: Could also just provide a bash script to fetch with wget. The script could then fetch other scripts? Yeah, that's probably the way to go in the end. But for now I'll be writting the individual scripts that that future script will orchestrate. - -### Install a few essentials. - ``` sudo apt install neovim git config --global core.editor "vim" diff --git a/config/bash/shadows.sh b/config/bash/shadows.sh new file mode 100644 index 0000000..ffee703 --- /dev/null +++ b/config/bash/shadows.sh @@ -0,0 +1,17 @@ +function tmux(){ + /usr/bin/tmux -f ~/.config/tmux/tmux.conf +} + +function lf() { + tmp="$(mktemp)" + lf0 -last-dir-path="$tmp" "$@" --command "set hidden" + if [ -f "$tmp" ]; then + dir="$(cat "$tmp")" + rm -f "$tmp" + if [ -d "$dir" ]; then + if [ "$dir" != "$(pwd)" ]; then + cd "$dir" + fi + fi + fi +} diff --git a/config/tmux/.tmux.conf b/config/tmux/.tmux.conf new file mode 100644 index 0000000..d1a4745 --- /dev/null +++ b/config/tmux/.tmux.conf @@ -0,0 +1,70 @@ +# Shortcuts +## See: https://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/ + +# remap prefix from 'C-b' to 'C-a' +unbind C-b +set-option -g prefix C-a +bind-key C-a send-prefix + +# No delay for escape key press +set -sg escape-time 0 + +## vim mode +setw -g mode-keys vi + +# selection +## https://www.rockyourcode.com/copy-and-paste-in-tmux/ +set-option -g mouse on +set-option -s set-clipboard off +bind P paste-buffer +bind-key -T copy-mode-vi v send-keys -X begin-selection +unbind -T copy-mode-vi Enter +bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel 'xclip -se c -i' +bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'xclip -se c -i' +bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'xclip -se c -i' + +## a long, long history +set-option -g history-limit 5000 + +# don't rename windows automatically +set-option -g allow-rename off +setw -g automatic-rename off + +# split panes using / and -, into the same directory +bind / split-window -h -c "#{pane_current_path}" +bind - split-window -v -c "#{pane_current_path}" +unbind '"' +unbind % + +# open new window into Documents directory with Ctrl+A+c +bind c new-window -c "~/Documents" # "bash -i -c 'lf && exec bash'" + +# switch panes using Alt-arrow without prefix +bind -n M-Left select-pane -L +bind -n M-Right select-pane -R +bind -n M-Up select-pane -U +bind -n M-Down select-pane -D + +# Use Alt-vim keys without prefix key to switch panes +bind -n M-h select-pane -L +bind -n M-j select-pane -D +bind -n M-k select-pane -U +bind -n M-l select-pane -R + +# Shift arrow to switch windows +bind -n S-Left previous-window +bind -n S-Right next-window + +## Get HOME and END keys to work in nvim. +## +bind-key -n Home send Escape "OH" +bind-key -n End send Escape "OF" + +# Reload config +bind r source-file ~/config/.tmux.conf + +## Disable status bar +bind-key b set -g status off + +# Terminal config +set -g default-terminal "xterm-256color" diff --git a/packages/core/1-bash.sh b/packages/core/1-bash.sh new file mode 100644 index 0000000..91724fd --- /dev/null +++ b/packages/core/1-bash.sh @@ -0,0 +1 @@ +echo "source ~/.config/bash/.bashrc" >> "~/.bashrc" diff --git a/packages/core/2-tmux.sh b/packages/core/2-tmux.sh new file mode 100644 index 0000000..f377d62 --- /dev/null +++ b/packages/core/2-tmux.sh @@ -0,0 +1 @@ +sudo apt install tmux