From d5ed46d9aaca461727f69e3db46f576d636b5445 Mon Sep 17 00:00:00 2001 From: kumaran-14 <32682103+kumaran-14@users.noreply.github.com> Date: Sun, 6 Oct 2024 16:25:50 -0500 Subject: [PATCH] Add vim inline editing --- README.md | 7 ++++++ miscellany/instructions.txt | 2 ++ miscellany/mori.sh | 45 +++++++++++++++++++++++++++++++++++++ zsh/.zprofile | 3 ++- zsh/.zshrc | 2 +- 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100755 miscellany/mori.sh diff --git a/README.md b/README.md index 9f1cede..7bd3285 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,13 @@ actual config is in /etc/X11/xorg.conf.backup note: i have manually backed up files in ~/.dotfiles/x11/ +#### Readline vi mode +Enabled by adding `set -o vi` in .zprofile +use ESC to trigger command mode to edit commands inline +use Ctrl-x followed by ctrl-e to open command in $VISUAL editor and edit and execute +checkout https://stackoverflow.com/questions/22655587/how-to-use-vi-to-edit-a-command-in-terminal-on-linux + + #### Grub Screen diff --git a/miscellany/instructions.txt b/miscellany/instructions.txt index 63df350..56a4186 100644 --- a/miscellany/instructions.txt +++ b/miscellany/instructions.txt @@ -5,3 +5,5 @@ Add this to end of defaults section, without quotes ###################### Some useful tips #################### # use \ to temporarily unalias the command for that execution alone # For example `\ls`, `\pacman` +# use the command word to do the same +# for example `command cat file.txt` diff --git a/miscellany/mori.sh b/miscellany/mori.sh new file mode 100755 index 0000000..e8664e5 --- /dev/null +++ b/miscellany/mori.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +RED="\033[41m \033[0m" +GREEN="\033[42m \033[0m" +GAP=" " + +birthdate="2000-03-14" +name="Kumaran" + +life_expectancy=65 +last_year_index=$((life_expectancy - 1)) + +case "$(uname)" in + "Linux") + birth_year=$(date -d "$birthdate" +"%Y") + birth_timestamp=$(date -d "$birthdate" +%s) + ;; + "Darwin") + birth_year=$(date -j -f "%Y-%m-%d" "$birthdate" +"%Y") + birth_timestamp=$(date -j -f "%Y-%m-%d" "$birthdate" +%s) + ;; + *) echo "Unsupported OS"; exit 1 ;; +esac + +current_year=$(date +"%Y") +current_timestamp=$(date +%s) +years_passed=$((current_year - birth_year)) +weeks_passed=$(( (current_timestamp - birth_timestamp) / 604800 )) +total_weeks=$((life_expectancy * 52)) +weeks_remaining=$((total_weeks - weeks_passed)) +last_year=$((birth_year + last_year_index)) +spent=$(( weeks_passed * 100 / total_weeks )) +width=$(tput cols) +red_blocks=$((weeks_passed * width / total_weeks)) + +echo "$name, only $weeks_remaining Sundays remain - $spent% ($weeks_passed) Sundays spent" +for (( block=0; block<$width; block++ )); do + if (( block <= red_blocks )) + then + echo -ne "${RED}" + else + echo -ne "${GREEN}" + fi +done +echo diff --git a/zsh/.zprofile b/zsh/.zprofile index 4bbe366..60c2933 100644 --- a/zsh/.zprofile +++ b/zsh/.zprofile @@ -18,7 +18,7 @@ fi # export EDITOR='vim' -export VISUAL='nano' +export VISUAL='vim' export PAGER='less' # @@ -69,3 +69,4 @@ fi # Added by `rbenv init` on Mon Aug 26 10:13:55 AM IST 2024 eval "$(~/.rbenv/bin/rbenv init - --no-rehash zsh)" +set -o vi diff --git a/zsh/.zshrc b/zsh/.zshrc index 7691e6c..2160f7b 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -56,4 +56,4 @@ done unset config_files ######################### END SOURCE ############################# - +/home/kumaran/.dotfiles/miscellany/mori.sh