Compare commits

...

4 commits

Author SHA1 Message Date
736e2f8eb8 Merge branch 'hotfix' into 'main'
Fix for vim fzf after the move to manually installing fzf

See merge request sagidayan/linux-config!10
2022-01-19 16:21:35 +00:00
47b2c0f476
Fix for vim fzf after the move to manually intalling fzf
Also added a `gitB` function for selecting branches from a list
2022-01-19 18:07:08 +02:00
443f4b1c5e Merge branch 'cleanups' into 'main'
Added ansible lint CI step.

See merge request sagidayan/linux-config!9
2022-01-19 15:30:13 +00:00
c512adf04d
Added ansible lint CI step.
Cleanup and lint fixes
2022-01-19 17:17:32 +02:00
15 changed files with 138 additions and 39 deletions

View file

@ -1,10 +1,26 @@
--- ---
stages: stages:
- ansible lint
- x86 Systems - x86 Systems
Ansible Lint:
stage: ansible lint
image:
name: fedora:latest
before_script:
- dnf install -y git ansible python3-ansible-lint
- export ANSIBLE_CONFIG=$(pwd)/ansible.cfg
- ./install-ansible-modules.sh
- ansible-lint --version
script:
- ansible-lint --force-color . &> lint-output.txt
- cat lint-output.txt
- if [ ! -z "$(cat lint-output.txt)" ]; then echo "Lint returned with warnings/fails"; exit 1; fi
Run Workstation playbook on fedora: Run Workstation playbook on fedora:
stage: x86 Systems stage: x86 Systems
image: fedora:latest image:
name: fedora:latest
script: script:
- dnf install -y ansible python3-pip - dnf install -y ansible python3-pip
- pip3 install -r ci-requirements.txt - pip3 install -r ci-requirements.txt
@ -18,7 +34,8 @@ Run Workstation playbook on fedora:
Run cli-tools playbook on centos: Run cli-tools playbook on centos:
stage: x86 Systems stage: x86 Systems
image: centos:latest image:
name: centos:latest
script: script:
- dnf install -y epel-release dnf-plugins-core - dnf install -y epel-release dnf-plugins-core
- dnf install -y --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-8.noarch.rpm - dnf install -y --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-8.noarch.rpm
@ -35,7 +52,8 @@ Run cli-tools playbook on centos:
Run Workstation playbook on ubuntu: Run Workstation playbook on ubuntu:
stage: x86 Systems stage: x86 Systems
image: ubuntu:latest image:
name: ubuntu:latest
script: script:
- export DEBIAN_FRONTEND=noninteractive - export DEBIAN_FRONTEND=noninteractive
- apt-get update - apt-get update
@ -53,7 +71,8 @@ Run Workstation playbook on ubuntu:
Run cli-tools playbook on debian: Run cli-tools playbook on debian:
stage: x86 Systems stage: x86 Systems
image: debian:latest image:
name: debian:latest
script: script:
- apt-get update - apt-get update
- apt-get install -y ansible python3-pip python3-apt - apt-get install -y ansible python3-pip python3-apt

View file

@ -4,16 +4,16 @@
######################################################## ########################################################
# Get docs fast # Get docs fast
selected=`cat ~/.shellconfig/cheat/topics | fzf --header="🏳️ Select a Topic: " --reverse` SELECTED=`cat ~/.shellconfig/cheat/topics | fzf --header="🏳️ Select a Topic: " --reverse`
if [[ -z $selected ]]; then if [[ -z $SELECTED ]]; then
exit 0 exit 0
fi fi
read -p "What you want to know?: " query read -p "🏳️ What do you want to know about ${SELECTED}?: " query
query=`echo $query | tr ' ' '+'` query=`echo $query | tr ' ' '+'`
if [[ $selected == "TLDR" ]]; then if [[ $SELECTED == "TLDR" ]]; then
tmux neww -n "[🏳️ Cheat: ${selected}/${query}]" bash -c "tldr ${query} | bat --paging=always --file-name='${selected} | Query: ${query}'" tmux neww -n "[🏳️ Cheat: ${SELECTED}/${query}]" bash -c "tldr ${query} | bat --paging=always --file-name='${SELECTED} | Query: ${query}'"
else else
tmux neww -n "[🏳️ Cheat: ${selected}/${query}]" bash -c "curl -s https://cht.sh/$selected/$query | bat --paging=always --file-name='Topic: ${selected} | Query: ${query}'" tmux neww -n "[🏳️ Cheat: ${SELECTED}/${query}]" bash -c "curl -s https://cht.sh/$SELECTED/$query | bat --paging=always --file-name='Topic: ${SELECTED} | Query: ${query}'"
fi fi

View file

@ -38,6 +38,41 @@ export EDITOR=vim;
# Shell functions # Shell functions
############################################ ############################################
function gitB() {
if [ -d ./.git ]; then
BRANCH=$(git branch -l | fzf --reverse --header="Select Branch to checkout")
if [ -z ${BRANCH} ]; then
echo Canceled
else
git ck ${BRANCH}
fi
else
echo "[ERROR]: Not in a git repository"
fi;
}
function huh() {
CURRENT_DIR=$(echo "${PWD##*/}")
TITLE="${1:=$CURRENT_DIR}"
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-="; \
echo "${TITLE}"; \
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-="; \
echo;echo Status:; \
echo -=-=-=-; \
git status; \
echo; \
echo Remotes:; \
echo -=-=-=-=; \
git remote -v | cat; \
echo;echo Files:; \
echo -=-=-=; \
ls -l; \
echo;echo;
}
function pre_check_tmux_for_layout() { function pre_check_tmux_for_layout() {
ERROR_PREFIX="[ERROR]: " ERROR_PREFIX="[ERROR]: "
@ -70,20 +105,8 @@ function ide() {
IDE_NAME="[⌨️ IDE: ${1:=$CURRENT_DIR}]" IDE_NAME="[⌨️ IDE: ${1:=$CURRENT_DIR}]"
pre_check_tmux_for_layout "ide" || return 1 pre_check_tmux_for_layout "ide" || return 1
clear;
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-="; \ huh "${IDE_NAME}";
echo "${IDE_NAME}"; \
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-="; \
echo;echo Status:; \
echo -=-=-=-; \
git status; \
echo; \
echo Remotes:; \
echo -=-=-=-=; \
git remote -v | cat; \
echo;echo Files:; \
echo -=-=-=; \
ls -l
tmux split-window -h -p 80 tmux split-window -h -p 80
tmux split-window -h -p 30 tmux split-window -h -p 30
tmux send-keys "gitui" C-m tmux send-keys "gitui" C-m

View file

@ -35,7 +35,7 @@ bind-key j send-keys Down
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded." bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded."
# Lookup the cheat sheet <prefix>-i # Lookup the cheat sheet <prefix>-i
bind-key i run-shell "tmux neww ~/.shellconfig/cheat.sh" bind-key i run-shell "tmux neww -n '🏳️ CHEATER\! 😎' ~/.shellconfig/cheat.sh"
############################ ############################
# Themes # Themes
########################### ###########################

View file

@ -21,6 +21,7 @@
Plug 'tpope/vim-fugitive' " git wrapper Plug 'tpope/vim-fugitive' " git wrapper
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } " golang plugin for vim Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } " golang plugin for vim
Plug 'Yggdroot/indentLine' " Indentation LInes Plug 'Yggdroot/indentLine' " Indentation LInes
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } " Install fzf
Plug 'junegunn/fzf.vim' " Fuzzy search Plug 'junegunn/fzf.vim' " Fuzzy search
Plug 'francoiscabrol/ranger.vim' " Ranger <leader>f Plug 'francoiscabrol/ranger.vim' " Ranger <leader>f
Plug 'scrooloose/nerdtree' " NerdTree - File tree (ctr-n) Plug 'scrooloose/nerdtree' " NerdTree - File tree (ctr-n)

6
install-ansible-modules.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
echo "===> Installing Ansible Dependencies"
ansible-galaxy collection install community.general
ansible-galaxy install hurricanehrndz.rustup

View file

@ -10,16 +10,19 @@
become: true become: true
package: package:
name: alacritty name: alacritty
state: latest state: present
- name: Setting up alacritty config file - name: Setting up alacritty config file
copy: copy:
src: dotfiles/alacritty.yml src: dotfiles/alacritty.yml
dest: ~/.alacritty.yml dest: ~/.alacritty.yml
mode: preserve
changed_when: false
- name: "Setting Alacritty theme" - name: "Setting Alacritty theme"
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: "~/.alacritty.yml" path: "~/.alacritty.yml"
regexp: "^colors:" regexp: "^colors:"
line: "colors: *{{theme}}" line: "colors: *{{ theme }}"
changed_when: false

View file

@ -25,11 +25,14 @@
src: dotfiles/gitconfig src: dotfiles/gitconfig
dest: ~/.gitconfig dest: ~/.gitconfig
force: no force: no
mode: preserve
- name: Setting up oh-my-zsh - name: Setting up oh-my-zsh
git: git:
repo: https://github.com/ohmyzsh/ohmyzsh.git repo: https://github.com/ohmyzsh/ohmyzsh.git
dest: ~/.oh-my-zsh dest: ~/.oh-my-zsh
version: master
- name: Making sure to use ZSH as shell - name: Making sure to use ZSH as shell
become: true become: true
@ -42,17 +45,20 @@
src: dotfiles/zshrc src: dotfiles/zshrc
dest: ~/.zshrc dest: ~/.zshrc
force: yes force: yes
mode: preserve
- name: Add ranger devicons plugin repo - name: Add ranger devicons plugin repo
git: git:
repo: https://github.com/alexanderjeurissen/ranger_devicons.git repo: https://github.com/alexanderjeurissen/ranger_devicons.git
dest: ~/.config/ranger/plugins/ranger_devicons dest: ~/.config/ranger/plugins/ranger_devicons
version: main
- name: Validate ranger config file - name: Validate ranger config file
changed_when: false changed_when: false
file: file:
path: ~/.config/ranger/rc.conf path: ~/.config/ranger/rc.conf
state: touch state: touch
mode: u=rw,g=r,o=r
- name: Activate ranger devicons plugin - name: Activate ranger devicons plugin
lineinfile: lineinfile:
@ -64,16 +70,19 @@
file: file:
path: ~/.shellconfig path: ~/.shellconfig
state: directory state: directory
mode: '0755'
- name: Verifying shell autocomplete config folder - name: Verifying shell autocomplete config folder
file: file:
path: ~/.shellconfig/autocomplete path: ~/.shellconfig/autocomplete
state: directory state: directory
mode: '0755'
- name: Verifying shell cheat config folder - name: Verifying shell cheat config folder
file: file:
path: ~/.shellconfig/cheat path: ~/.shellconfig/cheat
state: directory state: directory
mode: '0755'
- name: Sync Common shell settings... - name: Sync Common shell settings...
changed_when: false changed_when: false
@ -81,6 +90,7 @@
src: dotfiles/shellconfig/common.sh src: dotfiles/shellconfig/common.sh
dest: ~/.shellconfig/common.sh dest: ~/.shellconfig/common.sh
force: yes force: yes
mode: preserve
- name: Sync Cheat script - name: Sync Cheat script
changed_when: false changed_when: false
@ -95,24 +105,28 @@
src: dotfiles/shellconfig/aliases.sh src: dotfiles/shellconfig/aliases.sh
dest: ~/.shellconfig/aliases.sh dest: ~/.shellconfig/aliases.sh
force: no force: no
mode: preserve
- name: Copy shell functions - name: Copy shell functions
copy: copy:
src: dotfiles/shellconfig/functions.sh src: dotfiles/shellconfig/functions.sh
dest: ~/.shellconfig/functions.sh dest: ~/.shellconfig/functions.sh
force: no force: no
mode: preserve
- name: Copy shell environment - name: Copy shell environment
copy: copy:
src: dotfiles/shellconfig/environment.sh src: dotfiles/shellconfig/environment.sh
dest: ~/.shellconfig/environment.sh dest: ~/.shellconfig/environment.sh
force: no force: no
mode: preserve
- name: Copy topics cheat sheet list - name: Copy topics cheat sheet list
copy: copy:
src: dotfiles/shellconfig/cheat/topics src: dotfiles/shellconfig/cheat/topics
dest: ~/.shellconfig/cheat/topics dest: ~/.shellconfig/cheat/topics
force: yes force: yes
mode: preserve
- name: Install modern UNIX tools - name: Install modern UNIX tools
include_role: include_role:

View file

@ -33,6 +33,7 @@
- name: Check if open function is set - name: Check if open function is set
shell: grep -c "^function open" ~/.shellconfig/functions.sh || true shell: grep -c "^function open" ~/.shellconfig/functions.sh || true
register: open_test register: open_test
changed_when: false
- name: "Adding 'open' shell function" - name: "Adding 'open' shell function"
ansible.builtin.lineinfile: ansible.builtin.lineinfile:

View file

@ -5,6 +5,8 @@
state: directory state: directory
owner: root owner: root
group: root group: root
mode: '0755'
changed_when: false
- name: Installing Hack Nerd Font - name: Installing Hack Nerd Font
become: true become: true
@ -13,3 +15,4 @@
dest: /usr/share/fonts/hack/hack_nerd_font.ttf dest: /usr/share/fonts/hack/hack_nerd_font.ttf
owner: root owner: root
group: root group: root
mode: preserve

View file

@ -3,6 +3,7 @@
ansible.builtin.file: ansible.builtin.file:
state: directory state: directory
path: ~/.ansible_gh_release_versions path: ~/.ansible_gh_release_versions
mode: '0755'
- name: Setting local release file path - name: Setting local release file path
set_fact: set_fact:
@ -16,7 +17,8 @@
changed_when: false changed_when: false
- name: Get latest version tag from github - name: Get latest version tag from github
shell: echo {{ tar_url.stdout }} | grep -oP "(?<=download\/).*(?=\/)" shell:
cmd: 'echo {{ tar_url.stdout }} | grep -oP "(?<=download\/).*(?=\/)"'
changed_when: false changed_when: false
register: version register: version
@ -35,6 +37,13 @@
remote_src: yes remote_src: yes
when: version != local_version when: version != local_version
- name: Unarchive release source
ansible.builtin.unarchive:
src: "https://github.com/{{ repo }}/archive/refs/tags/{{ version }}.tar.gz"
dest: /tmp/
remote_src: yes
when: version != local_version and (include_source is defined)
- name: Moving bin to /usr/local/bin - name: Moving bin to /usr/local/bin
become: true become: true
shell: | shell: |
@ -50,12 +59,12 @@
- name: Update mandb if needed - name: Update mandb if needed
become: true become: true
shell: mandb shell: mandb || true
when: added_man is defined and (version != local_version) when: added_man is defined and (version != local_version)
- name: Adding autocomplete if needed - name: Adding autocomplete if needed
shell: | shell: |
cp /tmp/{{ autocomplete_path }} ~/.shellconfig/autocomplete/ cp /tmp/{{ autocomplete_path }} ~/.shellconfig/autocomplete/{{ name }}.autocomplete
when: autocomplete_path is defined and (version != local_version) when: autocomplete_path is defined and (version != local_version)
- name: Updating local version entry - name: Updating local version entry

View file

@ -1,4 +1,16 @@
--- ---
- name: Installing fzf
ansible.builtin.include_role:
name: gh_release_bin
vars:
name: fzf
repo: junegunn/fzf
bin_path: "/fzf"
autocomplete_path: "/fzf-*/shell/completion.zsh"
man_path: "/fzf-*/man/man1/fzf.1"
include_source: yes
filter: linux_amd64.tar.gz
- name: Installing bat (cat like) - name: Installing bat (cat like)
ansible.builtin.include_role: ansible.builtin.include_role:
name: gh_release_bin name: gh_release_bin
@ -7,7 +19,6 @@
repo: sharkdp/bat repo: sharkdp/bat
bin_path: "/bat-*/bat" bin_path: "/bat-*/bat"
man_path: "/bat-*/bat.1" man_path: "/bat-*/bat.1"
autocomplete_path: "/bat-*/autocomplete/bat.bash"
filter: x86_64-unknown-linux-gnu filter: x86_64-unknown-linux-gnu
- name: verify Bat (better Cat) theme - name: verify Bat (better Cat) theme
@ -15,10 +26,12 @@
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: "~/.shellconfig/common.sh" path: "~/.shellconfig/common.sh"
regexp: "^export BAT_THEME=" regexp: "^export BAT_THEME="
line: 'export BAT_THEME="${{theme}}"' line: 'export BAT_THEME="${{ theme }}"'
- name: Instaling TLDR (pip3) - name: Instaling TLDR (pip3)
shell: pip3 install tldr become: true
shell: pip3 install tldr || true
changed_when: false
- name: Installing bottom (btm) (Top like) - name: Installing bottom (btm) (Top like)
ansible.builtin.include_role: ansible.builtin.include_role:
@ -43,18 +56,21 @@
file: file:
path: ~/.config/gitui path: ~/.config/gitui
state: directory state: directory
mode: '0755'
- name: Copy gitui keybindings - name: Copy gitui keybindings
copy: copy:
src: dotfiles/gitui/key_config.ron src: dotfiles/gitui/key_config.ron
dest: ~/.config/gitui/key_config.ron dest: ~/.config/gitui/key_config.ron
force: yes force: yes
mode: preserve
- name: Copy gitui theme config - name: Copy gitui theme config
copy: copy:
src: dotfiles/gitui/theme.ron src: dotfiles/gitui/theme.ron
dest: ~/.config/gitui/theme.ron dest: ~/.config/gitui/theme.ron
force: yes force: yes
mode: preserve
- name: Installing LSD (ls like) - name: Installing LSD (ls like)
ansible.builtin.include_role: ansible.builtin.include_role:

View file

@ -2,15 +2,17 @@
become: true become: true
package: package:
name: tmux name: tmux
state: latest state: present
- name: Install tmux plugin manager - name: Install tmux plugin manager
git: git:
repo: https://github.com/tmux-plugins/tpm repo: https://github.com/tmux-plugins/tpm
dest: ~/.tmux/plugins/tpm dest: ~/.tmux/plugins/tpm
update: yes update: yes
version: master
- name: Copy tmux config file - name: Copy tmux config file
copy: copy:
src: dotfiles/tmux.conf src: dotfiles/tmux.conf
dest: ~/.tmux.conf dest: ~/.tmux.conf
mode: preserve

View file

@ -4,7 +4,7 @@
name: name:
- vim-X11 - vim-X11
- the_silver_searcher - the_silver_searcher
state: latest state: present
when: ansible_facts['os_family'] == "RedHat" when: ansible_facts['os_family'] == "RedHat"
- name: Install vim (Debian based) - name: Install vim (Debian based)
@ -20,6 +20,7 @@
file: file:
path: ~/.vim/autoload path: ~/.vim/autoload
state: directory state: directory
mode: '0755'
- name: Install vim Plug - name: Install vim Plug
get_url: get_url:
@ -30,12 +31,15 @@
copy: copy:
src: dotfiles/vimrc src: dotfiles/vimrc
dest: "~/.vimrc" dest: "~/.vimrc"
mode: preserve
changed_when: false
- name: "Set vim colorscheme" - name: "Set vim colorscheme"
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: "~/.vimrc" path: "~/.vimrc"
regexp: "^colorscheme" regexp: "^colorscheme"
line: "colorscheme base16-{{theme}}" line: "colorscheme base16-{{ theme }}"
changed_when: false
#- name: "Set vim lightline colorscheme" #- name: "Set vim lightline colorscheme"
# ansible.builtin.lineinfile: # ansible.builtin.lineinfile:

View file

@ -16,9 +16,7 @@ function print_fail_and_exit() {
echo "======> Running ${TARGET_PLAY}" echo "======> Running ${TARGET_PLAY}"
# Install Dependencies ./install-ansible-modules.sh
ansible-galaxy collection install community.general
ansible-galaxy install hurricanehrndz.rustup
# Run Playbook # Run Playbook
ANSIBLE_CONFIG=$(pwd)/ansible.cfg JUNIT_OUTPUT_DIR="/tmp/artifacts" ansible-playbook ${PLAYBOOK} || print_fail_and_exit ANSIBLE_CONFIG=$(pwd)/ansible.cfg JUNIT_OUTPUT_DIR="/tmp/artifacts" ansible-playbook ${PLAYBOOK} || print_fail_and_exit