From 76dce9a62c564070eb7a079a37a05ba5eb2355cf Mon Sep 17 00:00:00 2001 From: "jakob.stendahl" Date: Fri, 9 Feb 2024 11:35:20 +0100 Subject: some things --- .gitignore | 6 ++ Common/zshrc | 160 ----------------------------------------------- Common/zshrc.m4 | 157 ++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 29 +++++++++ install.sh | 13 ++++ install/install_linux.sh | 17 +++++ linux/tmux.conf | 125 ------------------------------------ linux/tmux.conf.m4 | 124 ++++++++++++++++++++++++++++++++++++ 8 files changed, 346 insertions(+), 285 deletions(-) delete mode 100644 Common/zshrc create mode 100644 Common/zshrc.m4 create mode 100644 Makefile delete mode 100644 linux/tmux.conf create mode 100644 linux/tmux.conf.m4 diff --git a/.gitignore b/.gitignore index 5246545..2c60df3 100644 --- a/.gitignore +++ b/.gitignore @@ -74,3 +74,9 @@ Common/vim/vim Common/nvim/plugin/ Common/nvim/lsp/jdt-language-server/workspace/folder/ Common/vim/netrwhist +system.m4 + +# Generated +Common/zshrc +linux/tmux.conf +linux/qtile/config/config.conf diff --git a/Common/zshrc b/Common/zshrc deleted file mode 100644 index 87f7b7c..0000000 --- a/Common/zshrc +++ /dev/null @@ -1,160 +0,0 @@ -# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. -# Initialization code that may require console input (password prompts, [y/n] -# confirmations, etc.) must go above this block; everything else may go below. -if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then - source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" -fi - -# If you come from bash you might have to change your $PATH. -export PATH=$HOME/bin:/usr/local/bin:$HOME/.local/bin:$PATH:$HOME/go/bin -export KEYTIMEOUT=1 - -# Check if env setup file exists -if [ ! -f ~/.zsh_env_setup ]; then - echo "export ZSH=$HOME/.oh-my-zsh" > ~/.zsh_env_setup - echo "DEFAULT_USER=$USER" >> ~/.zsh_env_setup - echo "export GIT_EDITOR=\"nvim\"" >> ~/.zsh_env_setup - echo "export GIT_AUTHOR_NAME=\"jakobst1n\"" >> ~/.zsh_env_setup - echo "export GIT_AUTHOR_EMAIL=\"jakob.stendahl@outlook.com\"" >> ~/.zsh_env_setup -fi - -# Source env setup file -source ~/.zsh_env_setup - -# Source powerlevel10k theme -case "$OSTYPE" in - darwin*) - source /usr/local/opt/powerlevel10k/powerlevel10k.zsh-theme;; - linux*) - ZSH_THEME="powerlevel10k/powerlevel10k";; -esac - -COMPLETION_WAITING_DOTS="true" - -ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=7,bold" - -# Setup plugins -plugins=( - git - zsh-autosuggestions - zsh-syntax-highlighting - #zsh-vi-mode -) - -# zsh-vi-mode-setup -#ZVM_CURSOR_STYLE_ENABLED=false -# zvm_config() { -# ZVM_INSERT_MODE_CURSOR=$ZVM_CURSOR_BLOCK -# ZVM_NORMAL_MODE_CURSOR=$ZVM_CURSOR_UNDERLINE -# ZVM_VISUAL_MODE_CURSOR=$ZVM_CURSOR_UNDERLINE -# ZVM_VISUAL_LINE_MODE_CURSOR=$ZVM_CURSOR_UNDERLINE -# ZVM_OPPEND_MODE_CURSOR=$ZVM_CURSOR_BLINKING_BLOCK -# } - -# Setup oh-my-zsh -source $ZSH/oh-my-zsh.sh - -# Modify locale and path -export LC_ALL=en_US.UTF-8 -export LANG=en_US.UTF-8 - -# Set editor -export EDITOR="nvim" - -# Enable vim keybindings (This is enabled using zsh-vi-mode now. -# bindkey -v - -# Add aliases -alias lsp="ps -ax | grep" -alias lsa="ls -la" -alias lsg="ls | grep" -alias lsag="ls -la | grep" -alias ls="tput setaf 3 && echo \"'lsa' for 'ls -la', \n'lsg' for 'ls | grep',\n'lsag' for 'ls -la | grep',\n'lsp' for 'ps -ax |grep'\" && tput sgr0 && ls" - -alias _vi=$(which vi) -alias _vim=$(which vim) -alias vi=nvim -alias vim=nvim - -# man pages in colors -man() { - LESS_TERMCAP_md=$'\e[01;31m' \ - LESS_TERMCAP_me=$'\e[0m' \ - LESS_TERMCAP_se=$'\e[0m' \ - LESS_TERMCAP_so=$'\e[01;44;33m' \ - LESS_TERMCAP_ue=$'\e[0m' \ - LESS_TERMCAP_us=$'\e[01;32m' \ - command man "$@" -} - -# Make tmux window title show the ssh hostname -# Make short hostname only if its not an IP address -__tm_get_hostname(){ - local HOST="$(echo $* | rev | cut -d ' ' -f 1 | rev)" - if echo $HOST | grep -P "^([0-9]+\.){3}[0-9]+" -q; then - echo $HOST - else - echo $HOST| cut -d . -f 1 - fi -} - -__tm_get_current_window(){ - tmux list-windows| awk -F : '/\(active\)$/{print $1}' -} - -# Rename window according to __tm_get_hostname and then restore it after the command -__tm_command() { - if [ "$(ps -p $(ps -p $$ -o ppid=) -o comm=| cut -d : -f 1)" = "tmux" ]; then - __tm_window=$(__tm_get_current_window) - # Use current window to change back the setting. If not it will be applied to the active window - trap "tmux set-window-option -t $__tm_window automatic-rename on 1>/dev/null" EXIT HUP INT QUIT PIPE TERM - tmux rename-window "$(__tm_get_hostname $*)" - command "$@" - tmux set-window-option -t $__tm_window automatic-rename on 1>/dev/null - else - command "$@" - fi -} - -ssh() { - __tm_command ssh "$@" -} - -ec2ssh() { - __tm_command ec2ssh "$@" -} - -[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh - -case "$OSTYPE" in - darwin*) - path+=("$(readlink /Users/$DEFAULT_USER/bin)") - path+=("/Library/TeX/texbin") - path+=("/usr/local/share/dotnet") - path+=("/usr/local/sbin") - path+=("/Users/jakobstendahl/.deta/bin") - path+=("/Applications/Racket v8.2/bin") - path+=("/Users/jakobstendahl/Library/Python/3.9/bin/") - export PATH - - alias krak='/Applications/GitKraken.app/Contents/MacOS/GitKraken -p "$(PWD)" &>> /dev/null &' - - #THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!! - export SDKMAN_DIR="/Users/jakobstendahl/.sdkman" - [[ -s "/Users/jakobstendahl/.sdkman/bin/sdkman-init.sh" ]] && source "/Users/jakobstendahl/.sdkman/bin/sdkman-init.sh" - ;; - linux*) - alias pbcopy='xsel --clipboard --input' - alias pbpaste='xsel --clipboard --output' - ;; -esac - -# start only one ssh-agent and reuse the created one -# this is used for sway, although keys added do not persist on reboot -SSH_DIR="$HOME" -if ! pgrep -u "$USER" ssh-agent > /dev/null; then - ssh-agent > "$SSH_DIR/ssh-agent.env" -fi -source "$SSH_DIR/ssh-agent.env" > /dev/null - -[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh diff --git a/Common/zshrc.m4 b/Common/zshrc.m4 new file mode 100644 index 0000000..c455782 --- /dev/null +++ b/Common/zshrc.m4 @@ -0,0 +1,157 @@ +m4_include(`system.m4')m4_dnl +# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. +# Initialization code that may require console input (password prompts, [y/n] +# confirmations, etc.) must go above this block; everything else may go below. +if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then + source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" +fi + +# If you come from bash you might have to change your $PATH. +export PATH=$HOME/bin:/usr/local/bin:$HOME/.local/bin:$PATH:$HOME/go/bin +export KEYTIMEOUT=1 + +# Check if env setup file exists +if [ ! -f ~/.zsh_env_setup ]; then + echo "export ZSH=$HOME/.oh-my-zsh" > ~/.zsh_env_setup + echo "DEFAULT_USER=$USER" >> ~/.zsh_env_setup + echo "export GIT_EDITOR=\"DEFAULT_EDITOR\"" >> ~/.zsh_env_setup + echo "export GIT_AUTHOR_NAME=\"GIT_USER\"" >> ~/.zsh_env_setup + echo "export GIT_AUTHOR_EMAIL=\"GIT_EMAIL\"" >> ~/.zsh_env_setup +fi + +# Source env setup file +source ~/.zsh_env_setup + +# Source powerlevel10k theme +m4_ifelse(OS_TYPE, `macos', `m4_dnl +source /usr/local/opt/powerlevel10k/powerlevel10k.zsh-theme +')m4_dnl +m4_ifelse(OS_TYPE, `linux', `m4_dnl +ZSH_THEME="powerlevel10k/powerlevel10k" +')m4_dnl + +COMPLETION_WAITING_DOTS="true" + +ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=7,bold" + +# Setup plugins +plugins=( + git + zsh-autosuggestions + zsh-syntax-highlighting + #zsh-vi-mode +) + +# zsh-vi-mode-setup +#ZVM_CURSOR_STYLE_ENABLED=false +# zvm_config() { +# ZVM_INSERT_MODE_CURSOR=$ZVM_CURSOR_BLOCK +# ZVM_NORMAL_MODE_CURSOR=$ZVM_CURSOR_UNDERLINE +# ZVM_VISUAL_MODE_CURSOR=$ZVM_CURSOR_UNDERLINE +# ZVM_VISUAL_LINE_MODE_CURSOR=$ZVM_CURSOR_UNDERLINE +# ZVM_OPPEND_MODE_CURSOR=$ZVM_CURSOR_BLINKING_BLOCK +# } + +# Setup oh-my-zsh +source $ZSH/oh-my-zsh.sh + +# Modify locale and path +export LC_ALL=en_US.UTF-8 +export LANG=en_US.UTF-8 + +# Set editor +export EDITOR="DEFAULT_EDITOR" + +# Enable vim keybindings (This is enabled using zsh-vi-mode now. +# bindkey -v + +# Add aliases +alias lsp="ps -ax | grep" +alias lsa="ls -la" +alias lsg="ls | grep" +alias lsag="ls -la | grep" +alias ls="tput setaf 3 && echo \"'lsa' for 'ls -la', \n'lsg' for 'ls | grep',\n'lsag' for 'ls -la | grep',\n'lsp' for 'ps -ax |grep'\" && tput sgr0 && ls" + +alias _vi=$(which vi) +alias _vim=$(which vim) +alias vi=nvim +alias vim=nvim + +# man pages in colors +man() { + LESS_TERMCAP_md=$'\e[01;31m' \ + LESS_TERMCAP_me=$'\e[0m' \ + LESS_TERMCAP_se=$'\e[0m' \ + LESS_TERMCAP_so=$'\e[01;44;33m' \ + LESS_TERMCAP_ue=$'\e[0m' \ + LESS_TERMCAP_us=$'\e[01;32m' \ + command man "$@" +} + +# Make tmux window title show the ssh hostname +# Make short hostname only if its not an IP address +__tm_get_hostname(){ + local HOST="$(echo $* | rev | cut -d ' ' -f 1 | rev)" + if echo $HOST | grep -P "^([0-9]+\.){3}[0-9]+" -q; then + echo $HOST + else + echo $HOST| cut -d . -f 1 + fi +} + +__tm_get_current_window(){ + tmux list-windows| awk -F : '/\(active\)$/{print $1}' +} + +# Rename window according to __tm_get_hostname and then restore it after the command +__tm_command() { + if [ "$(ps -p $(ps -p $$ -o ppid=) -o comm=| cut -d : -f 1)" = "tmux" ]; then + __tm_window=$(__tm_get_current_window) + # Use current window to change back the setting. If not it will be applied to the active window + trap "tmux set-window-option -t $__tm_window automatic-rename on 1>/dev/null" EXIT HUP INT QUIT PIPE TERM + tmux rename-window "$(__tm_get_hostname $*)" + command "$@" + tmux set-window-option -t $__tm_window automatic-rename on 1>/dev/null + else + command "$@" + fi +} + +ssh() { + __tm_command ssh "$@" +} + +ec2ssh() { + __tm_command ec2ssh "$@" +} + +[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh + +m4_ifelse(OS_TYPE, `macos', `m4_dnl +path+=("$(readlink /Users/$DEFAULT_USER/bin)") +path+=("/Library/TeX/texbin") +path+=("/usr/local/share/dotnet") +path+=("/usr/local/sbin") +path+=("/Users/jakobstendahl/.deta/bin") +path+=("/Applications/Racket v8.2/bin") +path+=("/Users/jakobstendahl/Library/Python/3.9/bin/") +export PATH + +#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!! +export SDKMAN_DIR="/Users/jakobstendahl/.sdkman" +[[ -s "/Users/jakobstendahl/.sdkman/bin/sdkman-init.sh" ]] && source "/Users/jakobstendahl/.sdkman/bin/sdkman-init.sh" +')m4_dnl +m4_ifelse(OS_TYPE, `linux', `m4_dnl +alias pbcopy="xsel --clipboard --input" +alias pbpaste="xsel --clipboard --output" +')m4_dnl + +# start only one ssh-agent and reuse the created one +# this is used for sway, although keys added do not persist on reboot +SSH_DIR="$HOME" +if ! pgrep -u "$USER" ssh-agent > /dev/null; then + ssh-agent > "$SSH_DIR/ssh-agent.env" +fi +source "$SSH_DIR/ssh-agent.env" > /dev/null + +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..71a9ebc --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ +M4 := m4 +M4_OPTS := -P +M4_COMMON_DEPS = system.m4 + +define M4_EXEC + ${M4} ${M4_OPTS} $< > $@ +endef + +TARGETS := linux/tmux.conf \ + Common/zshrc \ + linux/qtile/config/config.py + +all: $(TARGETS) + +linux/tmux.conf: linux/tmux.conf.m4 \ + ${M4_COMMON_DEPS} + $(call M4_EXEC) + +Common/zshrc: Common/zshrc.m4 \ + ${M4_COMMON_DEPS} + $(call M4_EXEC) + +linux/qtile/config/config.py: linux/qtile/config/config.py.m4 \ + linux/qtile/config/screen.m4.py \ + linux/qtile/config/group.m4.py \ + linux/qtile/config/layout.m4.py \ + linux/qtile/config/keys.m4.py \ + ${M4_COMMON_DEPS} + $(call M4_EXEC) diff --git a/install.sh b/install.sh index 909b269..f2d4b29 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,16 @@ #!/bin/bash +M4_DEF_FILE="system.m4" +echo "m4_define(\`DEFAULT_SHELL', \`/usr/bin/zsh')m4_dnl" > ${M4_DEF_FILE} +read -p "Enter dotfiles type: " dotfiles_type +echo "m4_define(\`DOTFILES_TYPE', \`${dotfiles_type}')m4_dnl" >> ${M4_DEF_FILE} +read -p "Enter git user: " git_user +echo "m4_define(\`GIT_USER', \`${git_user}')m4_dnl" >> ${M4_DEF_FILE} +read -p "Enter git email: " git_email +echo "m4_define(\`GIT_EMAIL', \`${git_email}')m4_dnl" >> ${M4_DEF_FILE} +read -p "Enter default editor: " default_editor +echo "m4_define(\`DEFAULT_EDITOR', \`${default_editor}')m4_dnl" >> ${M4_DEF_FILE} + if [ "$EUID" -eq 0 ]; then echo "Please don't run this as root, let sudo handle privilege escalation" exit 1 @@ -11,11 +22,13 @@ fi case "$OSTYPE" in darwin*) + echo "m4_define(\`OS_TYPE', \`macos')m4_dnl" >> ${M4_DEF_FILE} export INSTALLER_PM="brew" echo "Detected your OS as \"mac\"." ./install/install_mac.sh ;; linux*) + echo "m4_define(\`OS_TYPE', \`linux')m4_dnl" >> ${M4_DEF_FILE} echo "I detected that you are running linux, please enter your distro." tput setaf 4 echo "Please enter: \"arch\", \"fedora\" or \"debian\"" diff --git a/install/install_linux.sh b/install/install_linux.sh index e0d64ca..802d8c0 100755 --- a/install/install_linux.sh +++ b/install/install_linux.sh @@ -91,6 +91,23 @@ if [ $res -eq 1 ]; then tput rc; tput ed fi +dlgYN "> Install qtile" res +if [ $res -eq 1 ]; then + # tput sc + # # Core + # $INST_PM python3-cffi python3-cairocffi pango pango-devel python3-dbus-next + # # X11 + # $INST_PM python3-xcffib + # # Wayland + # $INST_PM wlroots python3-pywlroots python3-pywayland python3-xkbcommon xwayland + + # sudo pip install qtile qtile_extras + + sudo ln -isf "$CWD/linux/qtile/qtile.desktop" /usr/share/xsessions/qtile.desktop + sudo ln -isf "$CWD/linux/qtile/qtile-wayland.desktop" /usr/share/wayland-sessions/qtile-wayland.desktop + # tput rc; tput ed +fi + dlgYN "> Create symlinks" res if [ $res -eq 1 ]; then function createOrUpdateSymlink() { diff --git a/linux/tmux.conf b/linux/tmux.conf deleted file mode 100644 index c750770..0000000 --- a/linux/tmux.conf +++ /dev/null @@ -1,125 +0,0 @@ -# -- general ------------------------------------------------------------------- -#set -g default-terminal "screen-256color" -#set -g default-terminal "screen-256color-bce" -set -g default-terminal "xterm-256color" - -#set -as terminal-overrides ",*:U8=0" -#set-option -sa terminal-overrides ',xterm-256color:RGB' -set-option -ga terminal-overrides ",xterm-256color:Tc" - -set -s escape-time 0 # faster command sequences -set -s focus-events on - -# -- display ------------------------------------------------------------------- -set -g base-index 1 -setw -g pane-base-index 1 -setw -g automatic-rename on # rename window to reflect current program -set -g renumber-windows on # renumber windows when a window is closed - -set -g display-panes-time 800 # slightly longer pane indicators display time -set -g display-time 1000 # slightly longer status messages display time - -set -g status-interval 10 # redraw status linebg every 10 seconds -set-option -g history-limit 5000 - -set-option -g default-shell /usr/bin/zsh - -# -- navigation ---------------------------------------------------------------- - -# Set window notification -setw -g monitor-activity on -set -g visual-activity off - -unbind C-b -set -g prefix C-a -bind C-a send-prefix - -bind -n C-M-h resize-pane -L 2 -bind -n C-M-j resize-pane -D 2 -bind -n C-M-k resize-pane -U 2 -bind -n C-M-l resize-pane -R 2 - -# Set copying settings -setw -g mode-keys vi -set-option -s set-clipboard off -bind P paste-buffer -bind-key -T copy-mode-vi 'v' send -X begin-selection -bind-key -T copy-mode-vi 'r' send -X rectangle-toggle -bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel 'xclip -sel clip -i'` -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 MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'xclip -se c -ind-key -T copy-mode-vi Enter 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'' - -bind-key S-Left swap-window -t -1 -bind-key S-Right swap-window -t +1 - -bind -n End send-key C-e -bind -n Home send-key C-a - -# Bells -set -g visual-bell on -set -g bell-action any - -# Scroll in shell -#set -g terminal-overrides 'xterm*:smcup@:rmcup@' -#set -wg xterm-keys 1 -set -g mouse on -#set-option -s set-clipboard off - -# Sync panes -bind-key = set-window-option synchronize-panes - -# -- macros -------------------------------------------------------------------- -bind-key s send-keys \"jakob.stendahl\ \" - -# -- vim-tmux-navigator -------------------------------------------------------- -# Smart pane switching with awareness of Vim splits. -# See: https://github.com/christoomey/vim-tmux-navigator -is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ - | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" -bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L' -bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D' -bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U' -bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R' -tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")' -if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \ - "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'" -if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \ - "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'" - -bind-key -T copy-mode-vi 'C-h' select-pane -L -bind-key -T copy-mode-vi 'C-j' select-pane -D -bind-key -T copy-mode-vi 'C-k' select-pane -U -bind-key -T copy-mode-vi 'C-l' select-pane -R -bind-key -T copy-mode-vi 'C-\' select-pane -l - -# -- Utility ------------------------------------------------------------------ -bind-key r source-file ~/.tmux.conf - -bind -n M-w display-popup -E "nvim -c VimwikiIndex -c Calendar -c 'wincmd p'" -bind -n M-C-w display-popup -E "nvim -c VimwikiMakeDiaryNote -c Calendar -c 'wincmd p' -c 'call append(1, strftime(\"- **%T** - **\"))' -c 'call append(2, \"\")' -c 'execute \"normal! 2GA\"'" -bind -n M-C-i display-popup -E "nvim -c 'e ~/Nextcloud/wiki/I45/Hendelser.md' -c 'call append(1, strftime(\"- **%d.%m.%Y (%T)** - **\"))' -c 'call append(2, \"\")' -c 'execute \"normal! 2GA\"'" - -# -- Theme -------------------------------------------------------------------- -set -g status-justify left -set -g status-interval 2 -set -g status-position bottom -#set -g status-bg '#f8f8f8' -set -g status-bg '#F2EEDE' -set -g status-fg colour16 - -set -g status-left '#[fg=colour232,bg=colour3,bold]#{?client_prefix,C-a,}#[default] #[fg=colour0,bg=colour7,bold][#S]#[default] ' -set -g status-left-length 20 - -set -g status-right '#[fg=colour0,bg=colour7,bold] #(hostname) #[default] #[fg=colour0,bg=colour7,bold] %d/%m/%y #[default] #[fg=colour0,bg=colour7,bold] %H:%M:%S #[default] #[bg=colour7,bold] #(cat /sys/class/power_supply/BAT0/capacity)% #[default] ' -set -g status-right-length 50 - -setw -g window-status-format ' #I:#W#F ' -setw -g window-status-current-format ' #I:#W#F ' - -setw -g window-status-current-style "bg=colour0,fg=colour15" -setw -g window-status-style "bg=colour7,fg=colour0" -setw -g window-status-bell-style "bg=colour23,fg=colour15" -#setw -g window-status-activity-style "bg=colour23,fg=colour15" -setw -g window-status-activity-style "bg=colour243,fg=colour15" diff --git a/linux/tmux.conf.m4 b/linux/tmux.conf.m4 new file mode 100644 index 0000000..d47c78e --- /dev/null +++ b/linux/tmux.conf.m4 @@ -0,0 +1,124 @@ +m4_include(`system.m4')m4_dnl +# -- general ------------------------------------------------------------------- +#set -g default-terminal "screen-256color" +#set -g default-terminal "screen-256color-bce" +set -g default-terminal "xterm-256color" + +#set -as terminal-overrides ",*:U8=0" +#set-option -sa terminal-overrides ',xterm-256color:RGB' +set-option -ga terminal-overrides ",xterm-256color:Tc" + +set -s escape-time 0 # faster command sequences +set -s focus-events on + +# -- display ------------------------------------------------------------------- +set -g base-index 1 +setw -g pane-base-index 1 +setw -g automatic-rename on # rename window to reflect current program +set -g renumber-windows on # renumber windows when a window is closed + +set -g display-panes-time 800 # slightly longer pane indicators display time +set -g display-time 1000 # slightly longer status messages display time + +set -g status-interval 10 # redraw status linebg every 10 seconds +set-option -g history-limit 5000 + +set-option -g default-shell DEFAULT_SHELL + +# -- navigation ---------------------------------------------------------------- + +# Set window notification +setw -g monitor-activity on +set -g visual-activity off + +m4_ifelse(DOTFILES_TYPE, `local', `m4_dnl +unbind C-b +set -g prefix C-a +bind C-a send-prefix +')m4_dnl + +# Set copying settings +setw -g mode-keys vi +set-option -s set-clipboard off +bind P paste-buffer +bind-key -T copy-mode-vi 'v' send -X begin-selection +bind-key -T copy-mode-vi 'r' send -X rectangle-toggle +bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel 'xclip -sel clip -i'` +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 MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'xclip -se c -ind-key -T copy-mode-vi Enter 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'' + +# Bells +set -g visual-bell on +set -g bell-action any + +# Scroll in shell +#set -g terminal-overrides 'xterm*:smcup@:rmcup@' +#set -wg xterm-keys 1 +set -g mouse on +#set-option -s set-clipboard off + +# Sync panes +bind-key = set-window-option synchronize-panes + +# -- macros -------------------------------------------------------------------- +bind-key s send-keys "GIT_USER " + +# -- vim-tmux-navigator -------------------------------------------------------- +# Smart pane switching with awareness of Vim splits. +# this doesn't work, haven't checked why. chaning from vim to neovim could be it +# See: https://github.com/christoomey/vim-tmux-navigator +# is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ +# | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" +# bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L' +# bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D' +# bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U' +# bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R' +# tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")' +# if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \ +# "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'" +# if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \ +# "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'" +# +# bind-key -T copy-mode-vi 'C-h' select-pane -L +# bind-key -T copy-mode-vi 'C-j' select-pane -D +# bind-key -T copy-mode-vi 'C-k' select-pane -U +# bind-key -T copy-mode-vi 'C-l' select-pane -R +# bind-key -T copy-mode-vi 'C-\' select-pane -l + +# -- Utility ------------------------------------------------------------------ +bind-key r source-file ~/.tmux.conf + +bind -n M-w display-popup -E "nvim -c VimwikiIndex -c Calendar -c 'wincmd p'" +bind -n M-C-w display-popup -E "nvim -c VimwikiMakeDiaryNote -c Calendar -c 'wincmd p' -c 'call append(1, strftime(\"- **%T** - **\"))' -c 'call append(2, \"\")' -c 'execute \"normal! 2GA\"'" +bind -n M-C-i display-popup -E "nvim -c 'e ~/Nextcloud/wiki/I45/Hendelser.md' -c 'call append(1, strftime(\"- **%d.%m.%Y (%T)** - **\"))' -c 'call append(2, \"\")' -c 'execute \"normal! 2GA\"'" + +# -- Theme -------------------------------------------------------------------- +m4_ifelse(DOTFILES_TYPE, `local', `m4_dnl +set -g status-justify left +set -g status-interval 2 +set -g status-position bottom +#set -g status-bg "#f8f8f8" +set -g status-bg "#F2EEDE" +set -g status-fg colour16 + +set -g status-left "#[fg=colour232,bg=colour3,bold]#{?client_prefix,C-a,}#[default] #[fg=colour0,bg=colour7,bold][#S]#[default] " +set -g status-left-length 20 + +set -g status-right "#[fg=colour0,bg=colour7,bold] #(hostname) #[default] #[fg=colour0,bg=colour7,bold] %d/%m/%y #[default] #[fg=colour0,bg=colour7,bold] %H:%M:%S #[default] #[bg=colour7,bold] #(cat /sys/class/power_supply/BAT0/capacity)% #[default] " +set -g status-right-length 50 + +setw -g window-status-format " #I:#W#F " +setw -g window-status-current-format " #I:#W#F " + +setw -g window-status-current-style "bg=colour0,fg=colour15" +setw -g window-status-style "bg=colour7,fg=colour0" +setw -g window-status-bell-style "bg=colour23,fg=colour15" +#setw -g window-status-activity-style "bg=colour23,fg=colour15" +setw -g window-status-activity-style "bg=colour243,fg=colour15" +')m4_dnl +m4_ifelse(DOTFILES_TYPE, `remote', `m4_dnl +set -g status-bg "purple" +set -g status-fg "white" +')m4_dnl -- cgit v1.2.3