From f17255a3777cf8d348dd45cc2d7a5a099eb63f9f Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Mon, 10 Jan 2022 10:11:20 +0200 Subject: [PATCH] Added a short -i for cheat sheet (cht.sh) lookup --- files/dotfiles/shellconfig/cheat.sh | 20 +++++++++++++ files/dotfiles/shellconfig/cheat/commands | 35 ++++++++++++++++++++++ files/dotfiles/shellconfig/cheat/languages | 15 ++++++++++ files/dotfiles/shellconfig/common.sh | 1 - files/dotfiles/tmux.conf | 3 ++ playbooks/self-managed-unix-update.yml | 8 +++++ roles/base/tasks/main.yml | 26 +++++++++++++++- 7 files changed, 106 insertions(+), 2 deletions(-) create mode 100755 files/dotfiles/shellconfig/cheat.sh create mode 100644 files/dotfiles/shellconfig/cheat/commands create mode 100644 files/dotfiles/shellconfig/cheat/languages create mode 100644 playbooks/self-managed-unix-update.yml diff --git a/files/dotfiles/shellconfig/cheat.sh b/files/dotfiles/shellconfig/cheat.sh new file mode 100755 index 0000000..86c46e3 --- /dev/null +++ b/files/dotfiles/shellconfig/cheat.sh @@ -0,0 +1,20 @@ +#!/bin/bash +######################################################## +# DO NOT EDIT - WILL BE DISCARDED IN NEXT PLAYBOOK RUN # +######################################################## + +# Get docs fast +selected=`/bin/cat ~/.shellconfig/cheat/languages ~/.shellconfig/cheat/commands | fzf --header="Select a topic"` +if [[ -z $selected ]]; then + exit 0 +fi + +read -p "Enter Query: " query + +if grep -qs "$selected" ~/.shellconfig/cheat/languages; then + query=`echo $query | tr ' ' '+'` + tmux neww bash -c "echo \"curl cht.sh/$selected/$query/\" & curl cht.sh/$selected/$query & while [ : ]; do sleep 1; done" +else + tmux neww bash -c "curl -s cht.sh/$selected~$query | less" +fi + diff --git a/files/dotfiles/shellconfig/cheat/commands b/files/dotfiles/shellconfig/cheat/commands new file mode 100644 index 0000000..135e6b9 --- /dev/null +++ b/files/dotfiles/shellconfig/cheat/commands @@ -0,0 +1,35 @@ +find +fzf +man +tldr +sed +awk +tr +cp +ls +grep +xargs +ps +mv +kill +lsof +less +head +tail +tar +rm +jq +cat +ssh +cargo +git +podman +docker +docker-compose +chmod +chown +make +kubectl +oc +ocp +systemctl diff --git a/files/dotfiles/shellconfig/cheat/languages b/files/dotfiles/shellconfig/cheat/languages new file mode 100644 index 0000000..8693a22 --- /dev/null +++ b/files/dotfiles/shellconfig/cheat/languages @@ -0,0 +1,15 @@ +golang +nodejs +yaml +javascript +tmux +typescript +zsh +cpp +c +rust +python +bash +css +markdown +ansible diff --git a/files/dotfiles/shellconfig/common.sh b/files/dotfiles/shellconfig/common.sh index 3738db2..4266075 100644 --- a/files/dotfiles/shellconfig/common.sh +++ b/files/dotfiles/shellconfig/common.sh @@ -12,7 +12,6 @@ alias :Q=exit alias ls='lsd' alias f='printf "\033c"' -alias cat=bat alias top=btm alias t=tmux diff --git a/files/dotfiles/tmux.conf b/files/dotfiles/tmux.conf index 64bfbb2..dfdd6b1 100644 --- a/files/dotfiles/tmux.conf +++ b/files/dotfiles/tmux.conf @@ -33,6 +33,9 @@ bind-key j send-keys Down # Easy config reload bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded." + +# Lookup the cheat sheet -i +bind-key i run-shell "tmux neww ~/.shellconfig/cheat.sh" ############################ # Themes ########################### diff --git a/playbooks/self-managed-unix-update.yml b/playbooks/self-managed-unix-update.yml new file mode 100644 index 0000000..9cb30b4 --- /dev/null +++ b/playbooks/self-managed-unix-update.yml @@ -0,0 +1,8 @@ +- hosts: localhost + vars: + # Theme options: monokai, gruvbox, nord, tomorrow-night + theme: tomorrow-night + # The running user + running_user: "{{ ansible_user_id }}" + roles: + - modern_unix_tools diff --git a/roles/base/tasks/main.yml b/roles/base/tasks/main.yml index e89f142..e51106c 100644 --- a/roles/base/tasks/main.yml +++ b/roles/base/tasks/main.yml @@ -70,6 +70,11 @@ path: ~/.shellconfig/autocomplete state: directory +- name: Verifying shell cheat config folder + file: + path: ~/.shellconfig/cheat + state: directory + - name: Sync Common shell settings... changed_when: false copy: @@ -77,6 +82,14 @@ dest: ~/.shellconfig/common.sh force: yes +- name: Sync Cheat script + changed_when: false + copy: + src: dotfiles/shellconfig/cheat.sh + dest: ~/.shellconfig/cheat.sh + force: yes + mode: u+rx,g-rx,o-rwx + - name: Copy shell aliases copy: src: dotfiles/shellconfig/aliases.sh @@ -95,7 +108,18 @@ dest: ~/.shellconfig/environment.sh force: no - +- name: Copy languages cheat sheet list + copy: + src: dotfiles/shellconfig/cheat/languages + dest: ~/.shellconfig/cheat/languages + force: yes + +- name: Copy commands cheat sheet list + copy: + src: dotfiles/shellconfig/cheat/commands + dest: ~/.shellconfig/cheat/commands + force: yes + - name: Install modern UNIX tools include_role: name: modern_unix_tools