Skip to content

Commit

Permalink
Add vim inline editing
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaran-14 committed Oct 6, 2024
1 parent ec41cc6 commit d5ed46d
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions miscellany/instructions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ Add this to end of defaults section, without quotes
###################### Some useful tips ####################
# use \<command> 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`
45 changes: 45 additions & 0 deletions miscellany/mori.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion zsh/.zprofile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fi
#

export EDITOR='vim'
export VISUAL='nano'
export VISUAL='vim'
export PAGER='less'

#
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion zsh/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ done
unset config_files

######################### END SOURCE #############################

/home/kumaran/.dotfiles/miscellany/mori.sh

0 comments on commit d5ed46d

Please sign in to comment.