From 099625169d5a6407395b30586347c8cfeeaf1623 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sat, 29 Apr 2023 15:32:22 +0200 Subject: [PATCH] Aggiornato layout, inserito stub configurazione tmux. --- .gitignore | 1 + prepare.sh | 40 +++++++++++++++++++++++++++++ tmux.conf | 17 ++++++++++++ zsh/{ => distro}/archlinux.base.zsh | 0 zsh/{ => distro}/centos.base.zsh | 0 zsh/{ => distro}/debian.base.zsh | 0 zsh/distro/manjaro.base.zsh | 3 +++ zsh/distro/ubuntu.base.zsh | 1 + zsh/plugins/tmux.extra.conf | 2 ++ zsh/plugins/tmux.only.conf | 1 + zsh/plugins/tmux.plugin.zsh | 32 ++++++++++++----------- zshrc | 8 ++---- 12 files changed, 84 insertions(+), 21 deletions(-) create mode 100644 .gitignore create mode 100644 prepare.sh create mode 100644 tmux.conf rename zsh/{ => distro}/archlinux.base.zsh (100%) rename zsh/{ => distro}/centos.base.zsh (100%) rename zsh/{ => distro}/debian.base.zsh (100%) create mode 100644 zsh/distro/manjaro.base.zsh create mode 100644 zsh/distro/ubuntu.base.zsh create mode 100644 zsh/plugins/tmux.extra.conf create mode 100644 zsh/plugins/tmux.only.conf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5d51dea --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +zsh/distro.base.zsh diff --git a/prepare.sh b/prepare.sh new file mode 100644 index 0000000..f42baaf --- /dev/null +++ b/prepare.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +# copying all the needed stuff in place. +DOTFILES=${HOME}/.dotfiles + +# copying zshrc file +if [[ ! -f "$HOME/.zshrc" ]]; then + # no first setup done + + # Determining operating system so we can quickly setup basic configuration + if uname -a | grep -qi 'debian'; then + # Debian + sudo apt install -y zsh-autosuggestions zsh-syntax-highlighting + ln -sf ${DOTFILES}/zsh/distro/debian.base.zsh ${DOTFILES}/zsh/distro.base.zsh + fi + if uname -a | grep -qi 'ubuntu'; then + # TODO: complete instructions for Ubuntu + ln -sf ${DOTFILES}/zsh/distro/ubuntu.base.zsh ${DOTFILES}/zsh/distro.base.zsh + fi + if uname -a | grep -qi 'manjaro'; then + # TODO: complete instructions for Manjaro + pamac install manjaro-zsh-config + ln -sf ${DOTFILES}/zsh/distro/manjaro.base.zsh ${DOTFILES}/zsh/distro.base.zsh + fi + if uname -a | grep -qi 'archlinux'; then + pacman -S zsh-autosuggestions zsh-syntax-highlighting + ln -sf ${DOTFILES}/zsh/distro/archlinux.base.zsh ${DOTFILES}/zsh/distro.base.zsh + fi + if [[ -f /etc/redhat-release ]] && grep -qi centos /etc/redhat-release; then + # TODO: installation on centos. + ln -sf ${DOTFILES}/zsh/distro/centos.base.zsh ${DOTFILES}/zsh/distro.base.zsh + fi + + cp "${DOTFILES}/zshrc" "$HOME/.zshrc" +fi + +# Copying tmux configuration file and initialize plugins. +if [[ ! -f "$HOME/.tmux.conf" ]]; then + cp "${DOTFILES}/tmux.conf" "$HOME/.tmux.conf" +fi diff --git a/tmux.conf b/tmux.conf new file mode 100644 index 0000000..aa08179 --- /dev/null +++ b/tmux.conf @@ -0,0 +1,17 @@ +# Set tmux to use correct colors +set-option -sa terminal-overrides ",xterm*:Tc" +# Using mouse +set -g mouse on + +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-sensible' +set -g @plugin 'wfxr/tmux-power' +#set -g @tmux_power_theme 'sky' +set -g @tmux_power_theme '#3385ff' + +set -g @tmux_power_date_format '%d/%m/%Y' +set -g @tmux_power_time_format '%H:%M' +set -g @tmux_power_date_icon '' +set -g @tmux_power_time_icon '' + +run '~/.tmux/plugins/tpm/tpm' diff --git a/zsh/archlinux.base.zsh b/zsh/distro/archlinux.base.zsh similarity index 100% rename from zsh/archlinux.base.zsh rename to zsh/distro/archlinux.base.zsh diff --git a/zsh/centos.base.zsh b/zsh/distro/centos.base.zsh similarity index 100% rename from zsh/centos.base.zsh rename to zsh/distro/centos.base.zsh diff --git a/zsh/debian.base.zsh b/zsh/distro/debian.base.zsh similarity index 100% rename from zsh/debian.base.zsh rename to zsh/distro/debian.base.zsh diff --git a/zsh/distro/manjaro.base.zsh b/zsh/distro/manjaro.base.zsh new file mode 100644 index 0000000..b2140a4 --- /dev/null +++ b/zsh/distro/manjaro.base.zsh @@ -0,0 +1,3 @@ +# Configurations for Manjaro +source /usr/share/zsh/manjaro-zsh-config +source /usr/share/zsh/manjaro-zsh-prompt diff --git a/zsh/distro/ubuntu.base.zsh b/zsh/distro/ubuntu.base.zsh new file mode 100644 index 0000000..21216d0 --- /dev/null +++ b/zsh/distro/ubuntu.base.zsh @@ -0,0 +1 @@ +source /usr/share/powerlevel9k/powerlevel9k.zsh-theme diff --git a/zsh/plugins/tmux.extra.conf b/zsh/plugins/tmux.extra.conf new file mode 100644 index 0000000..c4aaad0 --- /dev/null +++ b/zsh/plugins/tmux.extra.conf @@ -0,0 +1,2 @@ +set -g default-terminal $ZSH_TMUX_TERM +source-file $ZSH_TMUX_CONFIG \ No newline at end of file diff --git a/zsh/plugins/tmux.only.conf b/zsh/plugins/tmux.only.conf new file mode 100644 index 0000000..0734df3 --- /dev/null +++ b/zsh/plugins/tmux.only.conf @@ -0,0 +1 @@ +set -g default-terminal $ZSH_TMUX_TERM diff --git a/zsh/plugins/tmux.plugin.zsh b/zsh/plugins/tmux.plugin.zsh index 654e8c3..311c2e6 100644 --- a/zsh/plugins/tmux.plugin.zsh +++ b/zsh/plugins/tmux.plugin.zsh @@ -1,20 +1,8 @@ -# vim:sts=2:sw=2:ft=zsh -# Taken from: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/tmux/tmux.plugin.zsh -# if ! (( $+commands[tmux] )); then print "zsh tmux plugin: tmux not found. Please install tmux before using this plugin." >&2 return 1 fi -# ALIASES - -alias ta='tmux attach -t' -alias tad='tmux attach -d -t' -alias ts='tmux new-session -s' -alias tl='tmux list-sessions' -alias tksv='tmux kill-server' -alias tkss='tmux kill-session -t' - # CONFIGURATION VARIABLES # Automatically start tmux : ${ZSH_TMUX_AUTOSTART:=false} @@ -42,6 +30,16 @@ alias tkss='tmux kill-session -t' # Set -u option to support unicode : ${ZSH_TMUX_UNICODE:=false} +# ALIASES + +alias ta='tmux attach -t' +alias tad='tmux attach -d -t' +alias ts='tmux new-session -s' +alias tl='tmux list-sessions' +alias tksv='tmux kill-server' +alias tkss='tmux kill-session -t' +alias tmuxconf='$EDITOR $ZSH_TMUX_CONFIG' + # Determine if the terminal supports 256 colors if [[ $terminfo[colors] == 256 ]]; then export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR @@ -75,7 +73,11 @@ function _zsh_tmux_plugin_run() { [[ "$ZSH_TMUX_UNICODE" == "true" ]] && tmux_cmd+=(-u) # Try to connect to an existing session. - [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach + if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then + [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach -t $ZSH_TMUX_DEFAULT_SESSION_NAME + else + [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach + fi # If failed, just run tmux, fixing the TERM variable if requested. if [[ $? -ne 0 ]]; then @@ -85,9 +87,9 @@ function _zsh_tmux_plugin_run() { tmux_cmd+=(-f "$ZSH_TMUX_CONFIG") fi if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then - $tmux_cmd new-session -s $ZSH_TMUX_DEFAULT_SESSION_NAME + $tmux_cmd new-session -s $ZSH_TMUX_DEFAULT_SESSION_NAME else - $tmux_cmd new-session + $tmux_cmd new-session fi fi diff --git a/zshrc b/zshrc index 53b62d6..1e1cd9c 100644 --- a/zshrc +++ b/zshrc @@ -1,7 +1,7 @@ # vim:sts=2:sw=2:ft=zsh # Base directories for dotfiles. -export DOTFILES=~/.dotfiles +export DOTFILES=${HOME}/.dotfiles # Autocompletion export FPATH=${DOTFILES}/zsh/functions:${FPATH} @@ -10,11 +10,7 @@ autoload -Uz compaudit compinit compinit # zsh packages from system -uname -a | grep -qi 'debian' && source ${DOTFILES}/zsh/debian.base.zsh -uname -a | grep -qi 'ubuntu' && source /usr/share/powerlevel9k/powerlevel9k.zsh-theme -uname -a | grep -qi 'manjaro' && source /usr/share/zsh/manjaro-zsh-config && source /usr/share/zsh/manjaro-zsh-prompt -uname -a | grep -qi 'archlinux' && source ${DOTFILES}/zsh/archlinux.base.zsh -test -f /etc/redhat-release && grep -qi centos /etc/redhat-release && source ${DOTFILES}/zsh/centos.base.zsh +source ${DOTFILES}/zsh/distro.base.zsh # Plugins for plugin in `find $DOTFILES/zsh/plugins -type f -iname \*.plugin.zsh -print`; do