diff options
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | Common/zshrc.m4 (renamed from Common/zshrc) | 61 | ||||
-rw-r--r-- | Makefile | 29 | ||||
-rwxr-xr-x | install.sh | 13 | ||||
-rwxr-xr-x | install/install_linux.sh | 17 | ||||
-rw-r--r-- | linux/tmux.conf.m4 (renamed from linux/tmux.conf) | 71 |
6 files changed, 129 insertions, 68 deletions
@@ -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.m4 index 87f7b7c..c455782 100644 --- a/Common/zshrc +++ b/Common/zshrc.m4 @@ -1,3 +1,4 @@ +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. @@ -13,21 +14,21 @@ export KEYTIMEOUT=1 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 + 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 -case "$OSTYPE" in - darwin*) - source /usr/local/opt/powerlevel10k/powerlevel10k.zsh-theme;; - linux*) - ZSH_THEME="powerlevel10k/powerlevel10k";; -esac +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" @@ -59,7 +60,7 @@ export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 # Set editor -export EDITOR="nvim" +export EDITOR="DEFAULT_EDITOR" # Enable vim keybindings (This is enabled using zsh-vi-mode now. # bindkey -v @@ -126,28 +127,24 @@ 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 +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 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) @@ -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.m4 index c750770..d47c78e 100644 --- a/linux/tmux.conf +++ b/linux/tmux.conf.m4 @@ -1,3 +1,4 @@ +m4_include(`system.m4')m4_dnl # -- general ------------------------------------------------------------------- #set -g default-terminal "screen-256color" #set -g default-terminal "screen-256color-bce" @@ -22,7 +23,7 @@ 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 +set-option -g default-shell DEFAULT_SHELL # -- navigation ---------------------------------------------------------------- @@ -30,14 +31,11 @@ set-option -g default-shell /usr/bin/zsh 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 - -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 +')m4_dnl # Set copying settings setw -g mode-keys vi @@ -51,12 +49,6 @@ 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 @@ -71,28 +63,29 @@ set -g mouse on bind-key = set-window-option synchronize-panes # -- macros -------------------------------------------------------------------- -bind-key s send-keys \"jakob.stendahl\ <jakob.stendahl@infomedia.dk>\" +bind-key s send-keys "GIT_USER <GIT_EMAIL>" # -- 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 +# 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 @@ -102,24 +95,30 @@ bind -n M-C-w display-popup -E "nvim -c VimwikiMakeDiaryNote -c Calendar -c 'win 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-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 "#[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 "#[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-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 |