From 0882a6a0c904eaf56b3d4ef0706467ae8db8b114 Mon Sep 17 00:00:00 2001 From: Ivan Reshetnikov Date: Sat, 13 Apr 2024 19:06:22 +0500 Subject: [PATCH] feat: add terminal configuration --- roles/terminal/files/alacritty.yml | 49 +++++++++++++++++++++++ roles/terminal/files/bash_aliases.sh | 3 ++ roles/terminal/files/bash_logout.sh | 7 ++++ roles/terminal/files/bashrc.sh | 59 ++++++++++++++++++++++++++++ roles/terminal/files/profile.sh | 23 +++++++++++ roles/terminal/tasks/alacritty.yml | 16 ++++++++ roles/terminal/tasks/bash.yml | 25 ++++++++++++ roles/terminal/tasks/main.yml | 4 ++ terminal.yml | 4 ++ 9 files changed, 190 insertions(+) create mode 100644 roles/terminal/files/alacritty.yml create mode 100644 roles/terminal/files/bash_aliases.sh create mode 100644 roles/terminal/files/bash_logout.sh create mode 100644 roles/terminal/files/bashrc.sh create mode 100644 roles/terminal/files/profile.sh create mode 100644 roles/terminal/tasks/alacritty.yml create mode 100644 roles/terminal/tasks/bash.yml create mode 100644 roles/terminal/tasks/main.yml create mode 100644 terminal.yml diff --git a/roles/terminal/files/alacritty.yml b/roles/terminal/files/alacritty.yml new file mode 100644 index 0000000..1eb25b1 --- /dev/null +++ b/roles/terminal/files/alacritty.yml @@ -0,0 +1,49 @@ +font: + normal: + family: JetBrains Mono + style: Regular + + bold: + family: JetBrains Mono + style: Bold + + italic: + family: JetBrains Mono + style: Italic + + bold_italic: + family: JetBrains Mono + style: Bold Italic + + size: 13 + +# Colors (Gruvbox dark) +colors: + # Default colors + primary: + # hard contrast: background = '0x1d2021' + background: '0x282828' + # soft contrast: background = '0x32302f' + foreground: '0xebdbb2' + + # Normal colors + normal: + black: '0x282828' + red: '0xcc241d' + green: '0x98971a' + yellow: '0xd79921' + blue: '0x458588' + magenta: '0xb16286' + cyan: '0x689d6a' + white: '0xa89984' + + # Bright colors + bright: + black: '0x928374' + red: '0xfb4934' + green: '0xb8bb26' + yellow: '0xfabd2f' + blue: '0x83a598' + magenta: '0xd3869b' + cyan: '0x8ec07c' + white: '0xebdbb2' diff --git a/roles/terminal/files/bash_aliases.sh b/roles/terminal/files/bash_aliases.sh new file mode 100644 index 0000000..3cb1acf --- /dev/null +++ b/roles/terminal/files/bash_aliases.sh @@ -0,0 +1,3 @@ +alias ls='ls --color=auto' +alias ll='ls -l' +alias grep='grep --color=auto' diff --git a/roles/terminal/files/bash_logout.sh b/roles/terminal/files/bash_logout.sh new file mode 100644 index 0000000..de4f5f7 --- /dev/null +++ b/roles/terminal/files/bash_logout.sh @@ -0,0 +1,7 @@ +# ~/.bash_logout: executed by bash(1) when login shell exits. + +# when leaving the console clear the screen to increase privacy + +if [ "$SHLVL" = 1 ]; then + [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q +fi diff --git a/roles/terminal/files/bashrc.sh b/roles/terminal/files/bashrc.sh new file mode 100644 index 0000000..4c22417 --- /dev/null +++ b/roles/terminal/files/bashrc.sh @@ -0,0 +1,59 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +shopt -s globstar + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" +fi + +# colored GCC warnings and errors +export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# Alias definitions. +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi diff --git a/roles/terminal/files/profile.sh b/roles/terminal/files/profile.sh new file mode 100644 index 0000000..4a58df8 --- /dev/null +++ b/roles/terminal/files/profile.sh @@ -0,0 +1,23 @@ +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login exists. +# see /usr/share/doc/bash/examples/startup-files for examples. +# the files are located in the bash-doc package. + +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi + diff --git a/roles/terminal/tasks/alacritty.yml b/roles/terminal/tasks/alacritty.yml new file mode 100644 index 0000000..81cc7e7 --- /dev/null +++ b/roles/terminal/tasks/alacritty.yml @@ -0,0 +1,16 @@ +- name: Install alacritty and JetBrains Mono font + become: true + ansible.builtin.apt: + pkg: + - alacritty + - fonts-jetbrains-mono +- name: Create alacritty config dir + ansible.builtin.file: + path: "{{ ansible_env.HOME }}/.config/alacritty" + state: directory + mode: '1770' +- name: Copy alacritty config + ansible.builtin.copy: + src: files/alacritty.yml + dest: "{{ ansible_env.HOME }}/.config/alacritty/alacritty.yml" + mode: '0660' diff --git a/roles/terminal/tasks/bash.yml b/roles/terminal/tasks/bash.yml new file mode 100644 index 0000000..42b5a72 --- /dev/null +++ b/roles/terminal/tasks/bash.yml @@ -0,0 +1,25 @@ +- name: Install bash + become: true + ansible.builtin.apt: + pkg: + - bash +- name: Copy bash config + ansible.builtin.copy: + src: files/bashrc.sh + dest: "{{ ansible_env.HOME }}/.bashrc" + mode: '0660' +- name: Copy bash aliases + ansible.builtin.copy: + src: files/bash_aliases.sh + dest: "{{ ansible_env.HOME }}/.bash_aliases" + mode: '0660' +- name: Copy profile + ansible.builtin.copy: + src: files/profile.sh + dest: "{{ ansible_env.HOME }}/.profile" + mode: '0660' +- name: Copy bash logout + ansible.builtin.copy: + src: files/profile.sh + dest: "{{ ansible_env.HOME }}/.bash_logout" + mode: '0660' diff --git a/roles/terminal/tasks/main.yml b/roles/terminal/tasks/main.yml new file mode 100644 index 0000000..2b942a9 --- /dev/null +++ b/roles/terminal/tasks/main.yml @@ -0,0 +1,4 @@ +- name: Bash + import_tasks: bash.yml +- name: Alacritty + import_tasks: alacritty.yml diff --git a/terminal.yml b/terminal.yml new file mode 100644 index 0000000..9fd8c8c --- /dev/null +++ b/terminal.yml @@ -0,0 +1,4 @@ +- name: Terminal + hosts: odhosts + roles: + - terminal