# Tmux Config

- Added Catppuccin theme
- Added kitty terminal config

# Sync and Rectify Vim & NVIM

- Undo files are incompatible between VIM & NVIM - saved those files separately
- Keybinding for saving and quitting moved to VIM config
- VIM & NVIM swapfiles removed
- More VIM options set to enhance usability
- Synced system vim config and keybindings with ideavimrc

# Shell Script File Changes

- Reverted to using `#!/bin/sh` as bash is slow and not POSIX compliant.
- Reformatted
This commit is contained in:
Pratik Tripathy
2024-01-02 23:45:41 +05:30
parent 0402ee5481
commit f780d7f6bd
20 changed files with 4378 additions and 1799 deletions

7
.gitignore vendored
View File

@@ -77,13 +77,8 @@ dist-ssr
*.min.js *.min.js
# Log files # Log files
logs ..logs/
*.log *.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
# Other Files to ignore # Other Files to ignore
**app_stat_v2.db **app_stat_v2.db

View File

@@ -21,4 +21,3 @@ Example: bash ./bootstrap.sh -q --create-links
I have multiple Linux installations on my machine. Linking it from one place (this repository) keeps things tidy. Also, changes to dotfiles automatically get applied to all the distros. I have multiple Linux installations on my machine. Linking it from one place (this repository) keeps things tidy. Also, changes to dotfiles automatically get applied to all the distros.
<!-- TODO: Move as many dotfiles inside ~/.config as possible --> <!-- TODO: Move as many dotfiles inside ~/.config as possible -->

View File

@@ -1,19 +1,19 @@
#!/bin/sh #!/bin/sh
usage() { usage() {
if [ -n "$1" ]; then if [ -n "$1" ]; then
echo "" echo ""
echo -e "${CRED}$1${CEND}\n" echo -e "${CRED}$1${CEND}\n"
fi fi
echo "Applies all settings stored in the script's directory to your home directory" echo "Applies all settings stored in the script's directory to your home directory"
echo "" echo ""
echo "Usage: $0 [-q|--quiet] [-l|--create-links]" echo "Usage: $0 [-q|--quiet] [-l|--create-links]"
echo " -q, --quiet No screen outputs" echo " -q, --quiet No screen outputs"
echo " -l, --create-links Creates soft-links to files in the current directory instead of copying them" echo " -l, --create-links Creates soft-links to files in the current directory instead of copying them"
echo "" echo ""
echo "Example: $0 -q --create-links" echo "Example: $0 -q --create-links"
} }
################################## ##################################
@@ -25,26 +25,26 @@ QUIET="n"
CREATE_LINKS="n" CREATE_LINKS="n"
while [[ "${#}" -gt 0 ]]; do while [[ "${#}" -gt 0 ]]; do
case $1 in case $1 in
-q | --quiet) -q | --quiet)
QUIET="y" QUIET="y"
shift shift
;; ;;
-l | --create-links) -l | --create-links)
CREATE_LINKS="y" CREATE_LINKS="y"
shift shift
;; ;;
-h | --help) -h | --help)
echo echo
usage usage
echo echo
exit 0 exit 0
;; ;;
*) *)
usage "Unknown parameter passed: $1" "h" usage "Unknown parameter passed: $1" "h"
exit 1 exit 1
;; ;;
esac esac
done done
main() { main() {

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/bin/sh
# Generic # Generic
alias sb="source ~/.bashrc" alias sb="source ~/.bashrc"
@@ -16,6 +16,7 @@ alias usersearch="awk -F: '{print \"UserName: \" \$1 \", UserID: \" \$3 \", Home
alias untar='tar -zxvf ' alias untar='tar -zxvf '
alias v=nvim alias v=nvim
alias n=nvim alias n=nvim
alias vim=nvim
url_encode(){ url_encode(){
python3 -c "import urllib.parse, sys; print(urllib.parse.quote(sys.stdin.read()))" <<< "$1" python3 -c "import urllib.parse, sys; print(urllib.parse.quote(sys.stdin.read()))" <<< "$1"
@@ -58,7 +59,7 @@ alias p1="ping1"
alias pubip="curl https://ipinfo.io/ip; echo" alias pubip="curl https://ipinfo.io/ip; echo"
alias speedtest="speedtest-cli --secure" # needs speedtest-cli installed alias speedtest="speedtest-cli --secure" # needs speedtest-cli installed
geoip () { geoip () {
curl -s https://ipinfo.io | sed '/readme/d;/loc/d;/postal/d;s/org/ISP/' | tr -d {},\" | awk -F ':' 'NF {printf ("%10s: %.25s \n", $1, $2)}' curl -s https://ipinfo.io | sed '/readme/d;/loc/d;/postal/d;s/org/ISP/' | tr -d {},\" | awk -F ':' 'NF {printf ("%10s: %.25s \n", $1, $2)}'
} }
@@ -66,7 +67,7 @@ geoip () {
# To use this - Ensure all git server SSH are in ~/.ssh # To use this - Ensure all git server SSH are in ~/.ssh
alias git_signin='(for i in ~/.ssh/{*github*,*gitea*}; do ssh-add -k $i; done; ) && (echo; echo Identities added successfully)' alias git_signin='(for i in ~/.ssh/{*github*,*gitea*}; do ssh-add -k $i; done; ) && (echo; echo Identities added successfully)'
git_push_all_changes(){ git_push_all_changes(){
git add . && git commit -am "${1}" && git push git add . && git commit -am "${1}" && git push
} }

View File

@@ -5,7 +5,7 @@
# If not running interactively, don't do anything # If not running interactively, don't do anything
case $- in case $- in
*i*) ;; *i*) ;;
*) return;; *) return ;;
esac esac
# append to the history file, don't overwrite it # append to the history file, don't overwrite it
@@ -29,7 +29,7 @@ fi
# set a fancy prompt (non-color, unless we know we "want" color) # set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in case "$TERM" in
xterm-color|*-256color) color_prompt=yes;; xterm-color|*-256color) color_prompt=yes ;;
esac esac
# uncomment for a colored prompt, if the terminal has the capability; turned # uncomment for a colored prompt, if the terminal has the capability; turned
@@ -39,12 +39,12 @@ esac
if [ -n "$force_color_prompt" ]; then if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48 # We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.) # a case would tend to support setf rather than setaf.)
color_prompt=yes color_prompt=yes
else else
color_prompt= color_prompt=
fi fi
fi fi
@@ -56,11 +56,11 @@ unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir # If this is an xterm set the title to user@host:dir
case "$TERM" in case "$TERM" in
xterm*|rxvt*) xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;; ;;
*) *)
;; ;;
esac esac
# enable color support of ls and also add handy aliases # enable color support of ls and also add handy aliases
@@ -95,11 +95,11 @@ fi
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc). # sources /etc/bash.bashrc).
if ! shopt -oq posix; then if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion . /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion . /etc/bash_completion
fi fi
fi fi
################################################################################ ################################################################################
@@ -121,7 +121,7 @@ shopt -s nullglob
shopt -s autocd shopt -s autocd
function timer_start { function timer_start {
timer=${timer:-$SECONDS} timer=${timer:-$SECONDS}
} }
trap 'timer_start' DEBUG trap 'timer_start' DEBUG
@@ -129,62 +129,62 @@ trap 'timer_start' DEBUG
PROMPT_COMMAND=jazz_my_prompt PROMPT_COMMAND=jazz_my_prompt
jazz_my_prompt() { jazz_my_prompt() {
# Capture exit code of last command # Capture exit code of last command
# Below MUST be the 1st line of the function # Below MUST be the 1st line of the function
local ex=$? local ex=$?
# Capture the last command's execution time # Capture the last command's execution time
timer_show=$(($SECONDS - $timer)) timer_show=$(($SECONDS - $timer))
unset timer unset timer
#----------------------------------------------------------------------------# #----------------------------------------------------------------------------#
# Bash text colour specification: \e[<COLOUR>;<STYLE>m # Bash text colour specification: \e[<COLOUR>;<STYLE>m
# Colours: 31=red, 32=green, 33=yellow, 34=blue, 35=purple, 36=cyan, 37=white # Colours: 31=red, 32=green, 33=yellow, 34=blue, 35=purple, 36=cyan, 37=white
# Styles: 0=normal, 1=bold, 2=dimmed, 4=underlined, 7=highlighted # Styles: 0=normal, 1=bold, 2=dimmed, 4=underlined, 7=highlighted
#----------------------------------------------------------------------------# #----------------------------------------------------------------------------#
local reset="\[\e[0m\]" local reset="\[\e[0m\]"
local normal=';0m' local normal=';0m'
local bold=';1m' local bold=';1m'
local boldyellow="\[\e[32${bold}\]" local boldyellow="\[\e[32${bold}\]"
local boldwhite="\[\e[37${bold}\]" local boldwhite="\[\e[37${bold}\]"
local normalwhite="\[\e[37${normal}\]" local normalwhite="\[\e[37${normal}\]"
local yellow_highlight="\[\e[31;7m\]" local yellow_highlight="\[\e[31;7m\]"
# Add color preference BEFORE the item # Add color preference BEFORE the item
local hostname="${normalwhite}\h" local hostname="${normalwhite}\h"
local username="${boldwhite}\u" local username="${boldwhite}\u"
local jobs="${boldwhite}jobs:\j" local jobs="${boldwhite}jobs:\j"
local history_cnt="${normalwhite}!\!" local history_cnt="${normalwhite}!\!"
local timestamp="${normalwhite}\D{%H:%M:%S(%z) %d%b}" local timestamp="${normalwhite}\D{%H:%M:%S(%z) %d%b}"
local session_cmd_cnt="${normalwhite}#\#" local session_cmd_cnt="${normalwhite}#\#"
local pwd="${boldwhite}\w" local pwd="${boldwhite}\w"
local isroot="${boldwhite}\$" local isroot="${boldwhite}\$"
# Set prompt content # Set prompt content
# If exit code of last command is non-zero, prepend this code to the prompt # If exit code of last command is non-zero, prepend this code to the prompt
local exit_code='' local exit_code=''
if [[ "$ex" -eq 0 ]] if [[ "$ex" -eq 0 ]]
then then
exit_code="${boldwhite}" exit_code="${boldwhite}"
else else
exit_code="${yellow_highlight}$ex\a${reset}" exit_code="${yellow_highlight}$ex\a${reset}"
fi fi
# Style each group separately # Style each group separately
local groupstart="${boldyellow}[" local groupstart="${boldyellow}["
local groupend="${boldyellow}]" local groupend="${boldyellow}]"
group1="${groupstart}${username}@${hostname}${groupend}" group1="${groupstart}${username}@${hostname}${groupend}"
group2="${groupstart}${jobs}${groupend}" group2="${groupstart}${jobs}${groupend}"
group3="${groupstart}${history_cnt}${groupend}" group3="${groupstart}${history_cnt}${groupend}"
group4="${groupstart}${session_cmd_cnt}${groupend}" group4="${groupstart}${session_cmd_cnt}${groupend}"
group5="${groupstart}${timestamp}${groupend}" group5="${groupstart}${timestamp}${groupend}"
group6="${groupstart}${exit_code}${groupend}" group6="${groupstart}${exit_code}${groupend}"
group8="${groupstart}${pwd}${groupend}" group8="${groupstart}${pwd}${groupend}"
group9="${groupstart}${normalwhite}${timer_show}s${groupend}" group9="${groupstart}${normalwhite}${timer_show}s${groupend}"
# Position each group where you would like them # Position each group where you would like them
PS1="\n${group1}-${group2}-${group3}-${group4}-${group5}\n${group6}-${group9}-${group8}\n${isroot}${reset} " PS1="\n${group1}-${group2}-${group3}-${group4}-${group5}\n${group6}-${group9}-${group8}\n${isroot}${reset} "
} }
# Setup path and export variables # Setup path and export variables

File diff suppressed because it is too large Load Diff

View File

@@ -1,2 +1,3 @@
-- Nvim Specific Configs that don't apply to VIM vim.opt.undodir = vim.fn.stdpath("config") .. "/undo"
vim.opt.backupdir = vim.fn.stdpath("config") .. "/backup/"

View File

@@ -1,8 +1,3 @@
-- <Ctrl-Alt-s> -> to save all files
vim.keymap.set({ "n", "i", "v" }, "<C-M-s>", "<cmd>wa<CR>", {})
-- <Ctrl-q> -> Save all files and quit Nvim
vim.keymap.set({ "n", "i", "v" }, "<C-q>", "<cmd>wqa<CR>", {})
-- Remap for dealing with word wrap -- Remap for dealing with word wrap
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })

View File

@@ -1,10 +1,9 @@
"""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""
" "
" Source common configs from VIM " Source common keymaps & configs from VIM
" "
"""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""
let $VIMDIR="$HOME/.vim" let $VIMDIR="$HOME/.vim"
let $NVIMDIR="$HOME/.config/nvim"
" Load VIM Configurations " Load VIM Configurations
source $VIMDIR/configs.vim source $VIMDIR/configs.vim
@@ -14,4 +13,3 @@ source $VIMDIR/key_maps.vim
" Save session files to $HOME/.vim/session directory " Save session files to $HOME/.vim/session directory
let g:session_dir="$VIMDIR/session" let g:session_dir="$VIMDIR/session"

View File

@@ -79,6 +79,9 @@ set -g @resurrect-capture-pane-contents "on"
set -g @resurrect-strategy-nvim "session" set -g @resurrect-strategy-nvim "session"
set -g @resurrect-dir "$HOME/.config/tmux/resurrect" set -g @resurrect-dir "$HOME/.config/tmux/resurrect"
# Don't exit tmux when closing a session
set -g detach-on-destroy off
#======================================================== #========================================================
# APPEARANCE # APPEARANCE
#======================================================== #========================================================
@@ -89,7 +92,8 @@ set -g renumber-windows on
set-window-option -g pane-base-index 1 set-window-option -g pane-base-index 1
# Improve colors # Improve colors
set -g default-terminal "xterm-256color" set -g default-terminal "${TERM}"
set-option -g default-terminal "xterm-256color"
set-option -sa terminal-overrides ",xterm*:Tc" set-option -sa terminal-overrides ",xterm*:Tc"
# Status at top # Status at top
@@ -101,23 +105,38 @@ set -g status-position top
run "~/.config/tmux/plugins/tpm/tpm" # Init Tmux Plugin Manager run "~/.config/tmux/plugins/tpm/tpm" # Init Tmux Plugin Manager
# TODO: Get into Tmux copy stuff when required # TODO: Get into Tmux copy stuff when required
# set -g @plugin 'tmux-plugins/tmux-yank'
# set -g @plugin "tmux-plugins/tmux-copycat"
set -g @plugin "christoomey/vim-tmux-navigator" # sync pane nav with Vim window nav set -g @plugin "christoomey/vim-tmux-navigator" # sync pane nav with Vim window nav
set -g @plugin "tmux-plugins/tmux-resurrect" # Persist sessions set -g @plugin "tmux-plugins/tmux-resurrect" # Persist sessions
set -g @plugin "tmux-plugins/tmux-continuum" # Auto save sessions every 15mins set -g @plugin "tmux-plugins/tmux-continuum" # Auto save sessions every 15mins
set -g @plugin 'tmux-plugins/tmux-yank' set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin "tmux-plugins/tmux-copycat" set -g @plugin "tmux-plugins/tmux-copycat"
set -g @plugin "fabioluciano/tmux-tokyo-night" set -g @plugin "catppuccin/tmux"
#======================================================== #========================================================
# PLUGINS Configurations # PLUGINS Configurations
#======================================================== #========================================================
# Color schemes # Color schemes
set -g @theme_variation "night" set -g @catppuccin_flavour "mocha"
set -g @theme_disable_plugins 1
set -g status-right "" set -g @catppuccin_window_left_separator ""
set -g @catppuccin_window_right_separator " "
set -g @catppuccin_window_middle_separator " █"
set -g @catppuccin_status_left_separator " "
set -g @catppuccin_status_right_separator " "
set -g @catppuccin_status_right_separator_inverse "no"
set -g @catppuccin_status_fill "icon"
set -g @catppuccin_window_current_text "#W"
set -g @catppuccin_window_current_fill "number"
set -g @catppuccin_window_default_text "#W"
set -g @catppuccin_window_default_fill "number"
set -g @catppuccin_window_status_enable "yes"
set -g @catppuccin_window_status_icon_enable "yes"
set -g @catppuccin_window_number_position "right"
set -g @catppuccin_status_connect_separator "no"
set -g @catppuccin_directory_text "#{pane_current_path}"
set -g @catppuccin_status_modules_right "session directory"
set -g @plugin "tmux-plugins/tpm" set -g @plugin "tmux-plugins/tpm"

View File

@@ -6,7 +6,7 @@ return {
font = wezterm.font_with_fallback({ font = wezterm.font_with_fallback({
-- "JetBrains Mono", -- "JetBrains Mono",
"JetBrainsMono Nerd Font", "JetBrainsMono Nerd Font",
{ family = "Symbols Nerd Font Mono", scale = 0.75 } { family = "Symbols Nerd Font Mono", scale = 0.75 },
}), }),
window_decorations = "RESIZE", window_decorations = "RESIZE",
enable_tab_bar = true, enable_tab_bar = true,
@@ -36,7 +36,7 @@ return {
event = { Up = { streak = 1, button = "Left" } }, event = { Up = { streak = 1, button = "Left" } },
mods = "CTRL", mods = "CTRL",
action = wezterm.action.OpenLinkAtMouseCursor, action = wezterm.action.OpenLinkAtMouseCursor,
} },
}, },
force_reverse_video_cursor = true, force_reverse_video_cursor = true,

View File

@@ -6,6 +6,9 @@
"source ~/.vimrc "source ~/.vimrc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
source ~/.vim/configs.vim
source ~/.vim/key_maps.vim
" Set Tabs to 4 characters " Set Tabs to 4 characters
set expandtab set expandtab
set tabstop=4 set tabstop=4
@@ -19,13 +22,8 @@ set incsearch " show search results while typing
set wrapscan " searches wrap around the end of the file set wrapscan " searches wrap around the end of the file
" Common settings " Common settings
set number " Show current line number
set relativenumber " Show relative line numbers
set gdefault " substitute all occurrences in line set gdefault " substitute all occurrences in line
set history=10000 " command line history
set scrolloff=5 sidescrolloff=10 " Keep some line before and after the cursor visible
set clipboard^=unnamed,unnamedplus,ideaput " Copy to and from system clipboard set clipboard^=unnamed,unnamedplus,ideaput " Copy to and from system clipboard
set nrfomats+=alpha,bin,octal,hex " Useful for auto incrementing
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enabled plugins " Enabled plugins
@@ -41,31 +39,16 @@ Plug 'tpope/vim-repeat' " Repeat for Surround
" Plug 'terryma/vim-multiple-cursors' " mc (selects), mx (skips), mp (previous) " Plug 'terryma/vim-multiple-cursors' " mc (selects), mx (skips), mp (previous)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" To see a list of all available :actions -> :actionlist
" Or select "IdeaVim: Track Action Ids" -> Copy the action id required
" Keymaps
let mapleader = " "
" Don't use Ex mode, use Q for formatting
map Q gq
" Map <leader>d to start debug " Map <leader>d to start debug
"map <leader>d <Action>(Debug) "map <leader>d <Action>(Debug)
" Map \b to toggle breakpoint " Map \b to toggle breakpoint
"map \b <Action>(ToggleLineBreakpoint) "map \b <Action>(ToggleLineBreakpoint)
" Center the cursor when doing 1/2 page down and page up
nnoremap <C-d> <C-d>zz
nnoremap <C-u> <C-u>zz
" Multiple Cursors " Multiple Cursors
map mc <A-n> map mc <A-n>
map mx <A-x> map mx <A-x>
map mp <A-p> map mp <A-p>
" Clear search highlighting
nnoremap <leader>/ :nohls<return><esc>
" Find/Open file " Find/Open file
nmap <leader>of :action GotoFile<CR> nmap <leader>of :action GotoFile<CR>
nmap <leader>or :action RecentFiles<CR> nmap <leader>or :action RecentFiles<CR>

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,7 @@
if [ -n "$BASH_VERSION" ]; then if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists # include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc" . "$HOME/.bashrc"
fi fi
fi fi
@@ -25,6 +25,3 @@ fi
if [ -d "$HOME/.local/bin" ] ; then if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH" PATH="$HOME/.local/bin:$PATH"
fi fi
# Remap caps lock to escape
setxkbmap -option caps:escape

View File

@@ -4,25 +4,28 @@ set omnifunc=syntaxcomplete#Complete
set complete+=kspell set complete+=kspell
set complete-=i set complete-=i
set completeopt="menuone,noselect" set completeopt="menuone,noselect"
set wildmenu " List and cycle through autocomplete on <Tab>
set wildignorecase " Case insensitive path completion
" Make sure tabs are 4 character wide " Make sure tabs are 4 character wide
set shiftwidth=4 tabstop=4 softtabstop=4 expandtab smarttab set shiftwidth=4 tabstop=4 softtabstop=4 expandtab smarttab
set autoindent smartindent breakindent set autoindent smartindent breakindent
syntax on " syntax highlighting. syntax on " Syntax highlighting.
syntax enable syntax enable
set cursorline " Hightlight cursor line set cursorline " Hightlight cursor line
set showmatch " Highlight matching braces set showmatch " Highlight matching braces
set ls=2 " Show a status line set noshowmode " Donot write "--INSERT--" etc.
set wrap " Wrap text set showcmd " Write out commands on status line
set wildmenu " Makes the ex command mode autocomplete paths with Tab set ls=2 " Show a status line
set number " Show line numbers set wrap " Wrap text
set number " Show line numbers
set ruler set ruler
set relativenumber " Relative line numbers set relativenumber " Relative line numbers
set shortmess+=I " Disable the default Vim startup message. set shortmess+=I " Disable the default Vim startup message.
set noerrorbells visualbell t_vb= " Disable audible bell because it's annoying. set noerrorbells visualbell t_vb= " Disable audible bell because it's annoying.
set mouse+=a " Enable mouse support set mouse+=a " Enable mouse support
set encoding=utf-8 " Encoding set encoding=utf-8 " Encoding
set autoread set autoread
set nrformats-=octal set nrformats-=octal
set formatoptions+=j set formatoptions+=j
@@ -39,11 +42,10 @@ set signcolumn=yes
set scrolloff=5 set scrolloff=5
set isfname+={,},@-@ set isfname+={,},@-@
set updatetime=50 set updatetime=50
set noswapfile
" Enable undofile and save them in ~/.vim/undo set undofile
set undofile " Enable undofiles set undolevels=10000
set undodir=$HOME/.vim/undo// " Save in each project's root set undoreload=100000
set directory^=$HOME/.vim/swap// " All swap files at the one place please
" Vim, by default, won't let you jump to a different file without saving the " Vim, by default, won't let you jump to a different file without saving the
" current one. With the below, unsaved files are just hidden. " current one. With the below, unsaved files are just hidden.
@@ -56,8 +58,8 @@ set incsearch hlsearch ignorecase smartcase
hi Comment guifg=#5C6370 ctermfg=50 cterm=italic hi Comment guifg=#5C6370 ctermfg=50 cterm=italic
" Highlight and remove trailing blank spaces on save " Highlight and remove trailing blank spaces on save
match ExtraWhitespace /\s\+$/
highlight ExtraWhitespace ctermbg=red guibg=red highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWritePre * %s/\s\+$//e autocmd BufWritePre * %s/\s\+$//e
" Vim is based on Vi. Setting `nocompatible` switches from the default " Vim is based on Vi. Setting `nocompatible` switches from the default
@@ -87,3 +89,6 @@ if !has('gui_running')
set termguicolors set termguicolors
endif endif
" NERDTree Plugin configurations
let g:NERDTreeShowHidden = 1
let g:NERDTreeWinSize = 25

View File

@@ -58,9 +58,10 @@ map <leader>j <Plug>(easymotion-s)
" Map nerdtree to <Leader>e " Map nerdtree to <Leader>e
" Changes the pwd and opens the VCS root " Changes the pwd and opens the VCS root
nnoremap <leader>e :tcd %:h<CR> :NERDTreeToggleVCS<CR> nnoremap <leader>e :tcd %:h<CR> :NERDTreeToggleVCS<CR>
let g:NERDTreeShowHidden = 1
let g:NERDTreeWinSize = 25
" <ctrl-q> to save everything and quit Neovim " <ctrl-q> to save everything and quit Neovim
nnoremap <C-q> :wqa<CR> nnoremap <C-q> :wqa<CR>
vnoremap <C-q> :wqa<CR>
nnoremap <C-s> :wa<CR>
vnoremap <C-s> :wa<CR>

View File

@@ -30,3 +30,6 @@ colorscheme deep-space
" Auto reload .vimrc " Auto reload .vimrc
autocmd! bufwritepost $VIMRC source % autocmd! bufwritepost $VIMRC source %
" Save inside vim config directory
set undodir=$VIMDIR/undo//

View File

@@ -2,7 +2,7 @@
# Initialization code that may require console input (password prompts, [y/n] # Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below. # confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi fi
# If you come from bash you might have to change your $PATH. # If you come from bash you might have to change your $PATH.
@@ -51,17 +51,17 @@ HIST_STAMPS="dd.mm.yyyy"
# Custom plugins may be added to $ZSH_CUSTOM/plugins/ # Custom plugins may be added to $ZSH_CUSTOM/plugins/
# source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh # source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
plugins=( plugins=(
git git
docker docker
history history
per-directory-history per-directory-history
perms perms
sudo sudo
systemd systemd
zsh-syntax-highlighting zsh-syntax-highlighting
zsh-autosuggestions zsh-autosuggestions
vi-mode vi-mode
# exercism # exercism
) )
source $ZSH/oh-my-zsh.sh source $ZSH/oh-my-zsh.sh

View File

@@ -1,15 +1,15 @@
#!/usr/bin/env bash #!/bin/sh
# Directories and Directory listings # Directories and Directory listings
dir_size(){ dir_size(){
local dir local dir
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
dir="${PWD}" dir="${PWD}"
else else
dir="$1" dir="$1"
fi fi
du -ah "${dir}" --max-depth=1 | sort -hr du -ah "${dir}" --max-depth=1 | sort -hr
} }
@@ -42,38 +42,38 @@ alias fpmreset73="sudo systemctl restart php7.3-fpm"
alias fpmreset74="sudo systemctl restart php7.4-fpm" alias fpmreset74="sudo systemctl restart php7.4-fpm"
f2b_banned_ips() { f2b_banned_ips() {
local provided_jail=$1 local provided_jail=$1
if [[ -n "${provided_jail// /}" ]]; then if [[ -n "${provided_jail// /}" ]]; then
for ip in $(sudo fail2ban-client status "${provided_jail}" | tail -1 | sed 's/[^:]*://;s/\s*//') for ip in $(sudo fail2ban-client status "${provided_jail}" | tail -1 | sed 's/[^:]*://;s/\s*//')
do do
printf "%17s\n" "$ip" printf "%17s\n" "$ip"
done done
else else
local total_ips_banned=0 local total_ips_banned=0
for JAIL in $(sudo fail2ban-client status | tail -1 | sed 's/[^:]*://;s/\s*//;s/,//g') for JAIL in $(sudo fail2ban-client status | tail -1 | sed 's/[^:]*://;s/\s*//;s/,//g')
do do
local banned_ip_count local banned_ip_count
banned_ip_count=$(sudo fail2ban-client status "${JAIL}" | grep -oP 'Currently banned:\s*\K\d+') banned_ip_count=$(sudo fail2ban-client status "${JAIL}" | grep -oP 'Currently banned:\s*\K\d+')
if [[ "${banned_ip_count}" -gt 0 ]]; then if [[ "${banned_ip_count}" -gt 0 ]]; then
echo "${JAIL}: ${banned_ip_count}" echo "${JAIL}: ${banned_ip_count}"
for ip in $(sudo fail2ban-client status "${JAIL}" | tail -1 | sed 's/[^:]*://;s/\s*//') for ip in $(sudo fail2ban-client status "${JAIL}" | tail -1 | sed 's/[^:]*://;s/\s*//')
do do
printf "%17s\n" "[$ip]" printf "%17s\n" "[$ip]"
done done
total_ips_banned=$(( total_ips_banned + banned_ip_count )) total_ips_banned=$(( total_ips_banned + banned_ip_count ))
echo echo
else else
echo -e "${JAIL}:\n -None-\n" echo -e "${JAIL}:\n -None-\n"
fi fi
done done
echo "Total IPs banned across all jails - ${total_ips_banned}" echo "Total IPs banned across all jails - ${total_ips_banned}"
fi fi
} }
f2b_unban_ip() { f2b_unban_ip() {
@@ -90,7 +90,7 @@ f2b_unban_ip() {
for JAIL in $(sudo fail2ban-client status | tail -1 | sed 's/[^:]*://;s/\s*//;s/,//g') for JAIL in $(sudo fail2ban-client status | tail -1 | sed 's/[^:]*://;s/\s*//;s/,//g')
do do
local banned_ip_count local banned_ip_count
banned_ip_count=$(sudo fail2ban-client status "${JAIL}" | grep -oP 'Currently banned:\s*\K\d+') banned_ip_count=$(sudo fail2ban-client status "${JAIL}" | grep -oP 'Currently banned:\s*\K\d+')
if [[ "$banned_ip_count" -gt 0 ]] && [[ $(sudo fail2ban-client status "${JAIL}") == *"${ip_to_unban}"* ]]; then if [[ "$banned_ip_count" -gt 0 ]] && [[ $(sudo fail2ban-client status "${JAIL}") == *"${ip_to_unban}"* ]]; then
local found_ip="true" local found_ip="true"
echo "Unbanning from ${JAIL}:" echo "Unbanning from ${JAIL}:"
@@ -99,21 +99,21 @@ f2b_unban_ip() {
done done
if [[ -z "${found_ip// /}" ]]; then if [[ -z "${found_ip// /}" ]]; then
echo "${ip_to_unban} was not found in any banned lists." echo "${ip_to_unban} was not found in any banned lists."
echo "No action taken." echo "No action taken."
fi fi
fi fi
} }
f2b_ban_an_ip(){ f2b_ban_an_ip(){
local ip_to_ban=$1 local ip_to_ban=$1
local ban_jail=$2 local ban_jail=$2
if [[ ( -z "${ip_to_ban// /}" ) || ( -z "${ban_jail// /}" ) ]]; then if [[ ( -z "${ip_to_ban// /}" ) || ( -z "${ban_jail// /}" ) ]]; then
echo "Please provide an IP and a Jail (in that order)" echo "Please provide an IP and a Jail (in that order)"
echo -e "eg -\n\t f2b_ban_an_ip 1.1.1.1 sshd" echo -e "eg -\n\t f2b_ban_an_ip 1.1.1.1 sshd"
return 1 return 1
fi fi
sudo fail2ban-client set "${ban_jail}" banip "${ip_to_ban}" > /dev/null && echo "Ban successful" sudo fail2ban-client set "${ban_jail}" banip "${ip_to_ban}" > /dev/null && echo "Ban successful"
} }

View File

@@ -1,18 +1,17 @@
#!/usr/bin/env bash #!/bin/sh
# Directories and Directory listings # Directories and Directory listings
dir_size(){ dir_size(){
local dir local dir
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
dir="${PWD}" dir="${PWD}"
else else
dir="$1" dir="$1"
fi fi
du -ah "${dir}" -d 1 | sort -hr du -ah "${dir}" -d 1 | sort -hr
} }
# Update & Upgrades # Update & Upgrades
alias up="brew upgrade --cask && brew upgrade --formula && rustup update && npm update -g" alias up="brew upgrade --cask && brew upgrade --formula && rustup update && npm update -g"