diff --git a/.prettierrc b/.prettierrc new file mode 120000 index 0000000..6d42b71 --- /dev/null +++ b/.prettierrc @@ -0,0 +1 @@ +common/.config/templates/.prettierrc \ No newline at end of file diff --git a/common/.config/nvim/lua/plugins/coding-cmp.lua b/common/.config/nvim/lua/plugins/coding-cmp.lua index 19836e0..097f464 100644 --- a/common/.config/nvim/lua/plugins/coding-cmp.lua +++ b/common/.config/nvim/lua/plugins/coding-cmp.lua @@ -19,16 +19,20 @@ return { "rafamadriz/friendly-snippets", }, config = function() - -- [[ Configure nvim-cmp ]] -- See `:help cmp` - -- vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) local cmp = require("cmp") local defaults = require("cmp.config.default")() local luasnip = require("luasnip") require("luasnip.loaders.from_vscode").lazy_load() luasnip.config.setup({}) + -- vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) cmp.setup({ + -- experimental = { + -- ghost_text = { + -- hl_group = "CmpGhostText", + -- }, + -- }, snippet = { expand = function(args) luasnip.lsp_expand(args.body) @@ -62,18 +66,13 @@ return { { name = "path" }, { { name = "buffer" } }, }, - -- experimental = { - -- ghost_text = { - -- hl_group = "CmpGhostText", - -- }, - -- }, sorting = defaults.sorting, }) end, }, { - "L4MON4D3/LuaSnip", + "L3MON4D3/LuaSnip", keys = { { "", diff --git a/common/.config/nvim/lua/plugins/coding-generic.lua b/common/.config/nvim/lua/plugins/coding-generic.lua index 01b90e3..323fd2d 100644 --- a/common/.config/nvim/lua/plugins/coding-generic.lua +++ b/common/.config/nvim/lua/plugins/coding-generic.lua @@ -1,9 +1,18 @@ return { { "tpope/vim-repeat" }, - { "tpope/vim-surround" }, { "easymotion/vim-easymotion" }, { "machakann/vim-highlightedyank" }, + -- Better surround than tpope/vim-surround + { + "kylechui/nvim-surround", + version = "*", + event = "VeryLazy", + config = function() + require("nvim-surround").setup({}) + end, + }, + -- "gc" to comment visual regions/lines { "numToStr/Comment.nvim", diff --git a/common/.config/nvim/lua/plugins/editor.lua b/common/.config/nvim/lua/plugins/editor.lua index 1317f83..3e3993d 100644 --- a/common/.config/nvim/lua/plugins/editor.lua +++ b/common/.config/nvim/lua/plugins/editor.lua @@ -216,6 +216,13 @@ return { end, desc = "Dismiss all Notifications", }, + { + "xx", + function() + require("notify").dismiss({ silent = true, pending = true }) + end, + desc = "Dismiss all Notifications", + }, }, opts = { render = "wrapped-compact", -- Smaller popups diff --git a/common/.config/nvim/lua/plugins/telescope.lua b/common/.config/nvim/lua/plugins/telescope.lua index bed5026..b25e856 100644 --- a/common/.config/nvim/lua/plugins/telescope.lua +++ b/common/.config/nvim/lua/plugins/telescope.lua @@ -54,8 +54,7 @@ return { pcall(require("telescope").load_extension, "fzf") -- Special Things: [T]elescope - vim.keymap.set("n", "nc", require("telescope.builtin").colorscheme, - { desc = "List [N]eovim [C]olorschemes (with preview)" }) + vim.keymap.set("n", "nc", require("telescope.builtin").colorscheme, { desc = "List [N]eovim [C]olorschemes (with preview)" }) -- Grep things -> [S]earch vim.keymap.set("n", "sb", function() @@ -63,46 +62,35 @@ return { grep_open_files = true, prompt_title = "Live Grep in Open Files", }) - end, { desc = "[S]earch Open [B]uffers" }) - vim.keymap.set("n", "sg", require("telescope.builtin").live_grep, - { desc = "[S]earch/Live[G]rep the Project" }) - vim.keymap.set("n", "sw", require("telescope.builtin").grep_string, - { desc = "[S]earch current [W]ord in Project" }) + end, { desc = "[S]earch Open [B]buffers" }) + vim.keymap.set("n", "sg", require("telescope.builtin").live_grep, { desc = "[S]earch/Live[G]rep the Project" }) + vim.keymap.set("n", "sw", require("telescope.builtin").grep_string, { desc = "[S]earch current [W]ord in Project" }) -- [L]ist - vim.keymap.set("n", "lb", require("telescope.builtin").buffers, { desc = "[L]ist [B]uffers" }) - vim.keymap.set("n", "lc", require("telescope.builtin").command_history, - { desc = "[L]ist NeoVIM [C]ommand History" }) - vim.keymap.set("n", "lf", require("telescope.builtin").find_files, - { desc = "[L]ist & Search [F]iles" }) - vim.keymap.set("n", "lh", require("telescope.builtin").help_tags, - { desc = "[L]ist & Search NeoVIM [H]elp" }) - vim.keymap.set("n", "lk", require("telescope.builtin").keymaps, - { desc = "[L]ist & Search NeoVIM [K]eymaps" }) - vim.keymap.set("n", "lm", require("telescope.builtin").man_pages, - { desc = "[L]ist & Search System Ma[n] Pages" }) - vim.keymap.set("n", "lq", require("telescope.builtin").quickfixhistory, - { desc = "[L]ist [Q]uickfix History" }) - vim.keymap.set("n", "ls", require("telescope.builtin").search_history, - { desc = "[L]ist [S]earch History" }) + vim.keymap.set("n", "lb", require("telescope.builtin").buffers, { desc = "[L]ist [B]buffers" }) + vim.keymap.set("n", "lc", require("telescope.builtin").command_history, { desc = "[L]ist NeoVIM [C]ommand History" }) + vim.keymap.set("n", "", require("telescope.builtin").find_files, { desc = "[L]ist & Search [F]iles" }) + vim.keymap.set("n", "lf", require("telescope.builtin").find_files, { desc = "[L]ist & Search [F]iles" }) + vim.keymap.set("n", "lh", require("telescope.builtin").help_tags, { desc = "[L]ist & Search NeoVIM [H]elp" }) + vim.keymap.set("n", "lk", require("telescope.builtin").keymaps, { desc = "[L]ist & Search NeoVIM [K]eymaps" }) + vim.keymap.set("n", "lm", require("telescope.builtin").man_pages, { desc = "[L]ist & Search System Ma[n] Pages" }) + vim.keymap.set("n", "lq", require("telescope.builtin").quickfixhistory, { desc = "[L]ist [Q]uickfix History" }) + vim.keymap.set("n", "ls", require("telescope.builtin").search_history, { desc = "[L]ist [S]earch History" }) vim.keymap.set("n", "lv", require("telescope.builtin").vim_options, { desc = "[L]ist [V]im Options" }) -- Git things -> [G]it - vim.keymap.set("n", "gb", require("telescope.builtin").git_branches, - { desc = "List [G]it [B]ranches" }) - vim.keymap.set("n", "gc", require("telescope.builtin").git_commits, { desc = "List [G]it [C]ommits" }) + vim.keymap.set("n", "gb", require("telescope.builtin").git_branches, { desc = "List [G]it [B]ranches" }) + vim.keymap.set("n", "gc", require("telescope.builtin").git_commits, { desc = "List [G]it [C]omits" }) -- LSP Things -> [C]oding - vim.keymap.set("n", "cd", require("telescope.builtin").diagnostics, - { desc = "[C]ode: List [D]iagnostics" }) + vim.keymap.set("n", "cd", require("telescope.builtin").diagnostics, { desc = "[C]ode: List [D]iagnostics" }) vim.keymap.set( "n", "ci", require("telescope.builtin").lsp_implementations, { desc = "[C]ode: Goto [I]mplementation of the word under cursor" } ) - vim.keymap.set("n", "cR", require("telescope.builtin").lsp_references, - { desc = "[C]ode: List [R]eferences for word under cursor" }) + vim.keymap.set("n", "cR", require("telescope.builtin").lsp_references, { desc = "[C]ode: List [R]eferences for word under cursor" }) vim.keymap.set( "n", "cgt", @@ -110,14 +98,10 @@ return { { desc = "[C]ode: Goto definition of the [T]ype under cursor" } ) vim.keymap.set("n", "gd", require("telescope.builtin").lsp_definitions, { desc = "[G]oto [D]efinition" }) - vim.keymap.set("n", "cgd", require("telescope.builtin").lsp_type_definitions, - { desc = "Type [D]efinition" }) - vim.keymap.set("n", "cR", require("telescope.builtin").lsp_references, - { desc = "[G]oto [R]eferences" }) - vim.keymap.set("n", "cI", require("telescope.builtin").lsp_implementations, - { desc = "[G]oto [I]mplementation" }) - vim.keymap.set("n", "cs", require("telescope.builtin").lsp_document_symbols, - { desc = "[D]ocument [S]ymbols" }) + vim.keymap.set("n", "cgd", require("telescope.builtin").lsp_type_definitions, { desc = "Type [D]efinition" }) + vim.keymap.set("n", "cR", require("telescope.builtin").lsp_references, { desc = "[G]oto [R]eferences" }) + vim.keymap.set("n", "cI", require("telescope.builtin").lsp_implementations, { desc = "[G]oto [I]mplementation" }) + vim.keymap.set("n", "cs", require("telescope.builtin").lsp_document_symbols, { desc = "[D]ocument [S]symbols" }) -- vim.keymap.set("n", "cgD", vim.lsp.buf.declaration, { desc = "[G]oto [D]eclaration" }) end, }, diff --git a/common/.config/nvim/lua/plugins/utility-plugs.lua b/common/.config/nvim/lua/plugins/utility-plugs.lua index c3d83ad..3a30806 100644 --- a/common/.config/nvim/lua/plugins/utility-plugs.lua +++ b/common/.config/nvim/lua/plugins/utility-plugs.lua @@ -52,7 +52,7 @@ return { opts = { -- Session files stored at: ~/.config/nvim/sessions/ dir = vim.fn.expand(vim.fn.stdpath("config") .. "/sessions/"), - options = vim.opt.sessionoptions:get() + options = vim.opt.sessionoptions:get(), -- NOTE: autocmd to autoload sessions at: ../config/autocmd.lua }, keys = { @@ -77,14 +77,4 @@ return { }, }, }, - - -- Provides tldr on vertical split - -- `:Tldr [command]` - { - "wlemuel/vim-tldr", - lazy = true, - dependencies = { - "nvim-telescope/telescope.nvim" - }, - }, } diff --git a/common/.config/shell/aliases.sh b/common/.config/shell/aliases.sh index 7c1fc91..88b77d2 100644 --- a/common/.config/shell/aliases.sh +++ b/common/.config/shell/aliases.sh @@ -10,15 +10,15 @@ alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias usersearch="awk -F: '{print \"UserName: \" \$1 \", UserID: \" \$3 \", Home Dir: \" \$6 \", Shell Used: \" \$7}' /etc/passwd | grep" alias untar='tar -zxvf ' -alias wget="wget --hsts-file ${WGET_HSTS_FILE}" +alias wget='wget --hsts-file ${WGET_HSTS_FILE}' -alias v="${EDITOR}" -alias snvim="${HOMEBREW_PREFIX}/bin/nvim" # Stable nvim +alias v='$EDITOR' +alias snvim='${HOMEBREW_PREFIX}/bin/nvim' # Stable nvim # Directories and Directory listings alias ~="cd ~" alias ..="cd .." -alias ...='cd ../../../' # Go back 3 directory levels +alias ...='cd ../../../' # Go back 3 directory levels alias cl=clear alias lsc='ls --color=auto --hyperlink' @@ -28,7 +28,7 @@ alias lsa="lsc -lAFhZ" alias mkdir="mkdir -pv" alias df="df -h" -mkcd () { +mkcd() { mkdir "$1" cd "$1" || exit } @@ -41,7 +41,6 @@ alias p8="ping8" alias p1="ping1" alias pubip="curl https://ipinfo.io/ip; echo" alias speedtest="speedtest-cli --secure" -geoip () { +geoip() { curl -s https://ipinfo.io | sed '/readme\|loc\|postal\|{\|}\|hostname/d;s/org/ISP/;s/"\|,$//g' | awk -F ':' 'NF { printf("%10s: %s \n", $1, $2)}' } - diff --git a/common/.gitignore b/common/.config/templates/.gitignore similarity index 100% rename from common/.gitignore rename to common/.config/templates/.gitignore diff --git a/common/.config/templates/.prettierrc b/common/.config/templates/.prettierrc new file mode 100644 index 0000000..5dec022 --- /dev/null +++ b/common/.config/templates/.prettierrc @@ -0,0 +1,7 @@ +{ + "tabWidth": 4, + "useTabs": false, + "semi": true, + "singleQuote": false, + "trailingComma": "all" +} diff --git a/common/.profile b/common/.profile index 40ce4ff..759ee99 100644 --- a/common/.profile +++ b/common/.profile @@ -1,3 +1,5 @@ +#!/bin/sh + [ ! -f "/home/linuxbrew/.linuxbrew/bin/brew" ] || eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" # set PATH so it includes user's private bin if it exists @@ -11,35 +13,38 @@ [ ! -d "$HOME/.local/bin" ] || PATH="$PATH:$HOME/.local/bin" # Set the config directory environment variable -[ -n "$XDG_CONFIG_HOME" ] || export XDG_CONFIG_HOME="$HOME/.config" +[ "$XDG_CONFIG_HOME" != "" ] || export XDG_CONFIG_HOME="$HOME/.config" # Set the cache directory environment variable -[ -n "$XDG_CACHE_HOME" ] || export XDG_CACHE_HOME="$HOME/.cache" +[ "$XDG_CACHE_HOME" != "" ] || export XDG_CACHE_HOME="$HOME/.cache" # Set the data directory environment variable -[ -n "$XDG_DATA_HOME" ] || export XDG_DATA_HOME="$HOME/.local/share" +[ "$XDG_DATA_HOME" != "" ] || export XDG_DATA_HOME="$HOME/.local/share" # Set the state directory environment variable -[ -n "$XDG_STATE_HOME" ] || export XDG_STATE_HOME="$HOME/.local/state" +[ "$XDG_STATE_HOME" != "" ] || export XDG_STATE_HOME="$HOME/.local/state" ################################################################################## eval "$(ssh-agent -s)" >/dev/null ulimit -n 10240 +[ ! -f "$XDG_CONFIG_HOME/templates/.gitignore" ] || export GITIGNORE_TEMPLATE="$XDG_CONFIG_HOME/templates/.gitignore" +[ ! -f "$XDG_CONFIG_HOME/templates/.prettierrc" ] || export PRETTIER_TEMPLATE="$XDG_CONFIG_HOME/templates/.prettierrc" + EDITOR=$(command -v nvim 2>/dev/null || command -v vim 2>/dev/null) export EDITOR -export VISUAL=$EDITOR +export VISUAL="$EDITOR" # Manually follow steps from https://steamcommunity.com/app/646570/discussions/1/3935537639868400686 # To disable ~/.oracle_jre_usage/ from being created if [ "$(uname -s)" = "Linux" ]; then - export __GL_SHADER_DISK_CACHE_PATH="$XDG_CACHE_HOME/nvidia" + export __GL_SHADER_DISK_CACHE_PATH="$XDG_CACHE_HOME/nvidia" - # Needs upstream fix to work: https://bugs.kde.org/show_bug.cgi?id=415770 - export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc-2.0" - export CUDA_CACHE_PATH="XDG_CACHE_HOME/nv" + # Needs upstream fix to work: https://bugs.kde.org/show_bug.cgi?id=415770 + export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc-2.0" + export CUDA_CACHE_PATH="XDG_CACHE_HOME/nv" # Map caps-lock to escape TIP: also added to /etc/profile setxkbmap -option caps:escape @@ -48,7 +53,7 @@ fi export QT_PLUGIN_PATH="$HOME/local/lib/qt/plugins/:" if [ "$XDG_SESSION_DESKTOP" = "KDE" ]; then - export KDEHOME="$XDG_CONFIG_HOME/KDE" + export KDEHOME="$XDG_CONFIG_HOME/KDE" fi export GNUPGHOME="$XDG_CONFIG_HOME/gnupg" @@ -94,6 +99,6 @@ export AWS_SHARED_CREDENTIALS_FILE="$XDG_CONFIG_HOME/aws/credentials" export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker" export FZF_DEFAULT_COMMAND='rg --files --hidden' -export FZF_DEFAULT_OPTS='--layout=reverse --inline-info --height=~50% --border' +export FZF_DEFAULT_OPTS='--layout=reverse --cycle --inline-info --height=~50% --border' export TLDR_CACHE_DIR="$XDG_CACHE_HOME/tldr" diff --git a/common/.vscode/argv.json b/common/.vscode/argv.json new file mode 100644 index 0000000..3e25892 --- /dev/null +++ b/common/.vscode/argv.json @@ -0,0 +1,24 @@ +// This configuration file allows you to pass permanent command line arguments to VS Code. +// Only a subset of arguments is currently supported to reduce the likelyhood of breaking +// the installation. +// +// PLEASE DO NOT CHANGE WITHOUT UNDERSTANDING THE IMPACT +// +// NOTE: Changing this file requires a restart of VS Code. +{ + // Use software rendering instead of hardware accelerated rendering. + // This can help in cases where you see rendering issues in VS Code. + // "disable-hardware-acceleration": true, + + // Enabled by default by VS Code to resolve color issues in the renderer + // See https://github.com/Microsoft/vscode/issues/51791 for details + "disable-color-correct-rendering": true, + + // Allows to disable crash reporting. + // Should restart the app if the value is changed. + "enable-crash-reporter": false, + + // Unique id used for correlating crash reports sent from this instance. + // Do not edit this value. + "crash-reporter-id": "663adebd-ee7d-4d1f-9723-fd963e7e8e1a" +} \ No newline at end of file diff --git a/common/.vscode/settings.json b/common/.vscode/settings.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/common/.vscode/settings.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/kde-neon/.config/shell/aliases_neon.sh b/kde-neon/.config/shell/aliases_neon.sh index b2cb68a..d1e86fc 100644 --- a/kde-neon/.config/shell/aliases_neon.sh +++ b/kde-neon/.config/shell/aliases_neon.sh @@ -2,14 +2,13 @@ # Directories and Directory listings dir_size(){ - local dir - if [ -z "$1" ]; then - dir="${PWD}" + if [ "$1" = "" ]; then + dir="$PWD" else dir="$1" fi - du -ah "${dir}" --max-depth=1 | sort -hr + du -ah "$dir" --max-depth=1 | sort -hr } alias tldr="tldr --platform=linux " @@ -43,24 +42,23 @@ alias fpmreset73="sudo systemctl restart php7.3-fpm" alias fpmreset74="sudo systemctl restart php7.4-fpm" f2b_banned_ips() { - local provided_jail=$1 + provided_jail=$1 - if [ -n "${provided_jail// /}" ]; then - for ip in $(sudo fail2ban-client status "${provided_jail}" | tail -1 | sed 's/[^:]*://;s/\s*//') + if [ "${provided_jail// /}" != "" ]; then + for ip in "$(sudo fail2ban-client status "$provided_jail" | tail -1 | sed 's/[^:]*://;s/\s*//')" do printf "%17s\n" "$ip" done else - local total_ips_banned=0 - for JAIL in $(sudo fail2ban-client status | tail -1 | sed 's/[^:]*://;s/\s*//;s/,//g') + total_ips_banned=0 + for JAIL in "$(sudo fail2ban-client status | tail -1 | sed 's/[^:]*://;s/\s*//;s/,//g')" do - 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}" - 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 printf "%17s\n" "[$ip]" done @@ -78,24 +76,23 @@ f2b_banned_ips() { } f2b_unban_ip() { - local ip_to_unban="$1" - local jail="$2" + ip_to_unban="$1" + jail="$2" # If jail is provided - use that jail to directly unban - if [ -n "${jail// /}" ]; then - sudo fail2ban-client set "${jail}" unbanip "${ip_to_unban}" > /dev/null && echo "Successfully released ban" + if [ "${jail// /}" != "" ]; then + sudo fail2ban-client set "$jail" unbanip "$ip_to_unban" > /dev/null && echo "Successfully released ban" else # Find all JAILS this IP belong to # Unban the ip where ever it is found - 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 - local banned_ip_count - 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 - local found_ip="true" + 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 + found_ip="true" echo "Unbanning from ${JAIL}:" - sudo fail2ban-client set "${JAIL}" unbanip "${ip_to_unban}" > /dev/null && echo "Successfully released ban" + sudo fail2ban-client set "$JAIL" unbanip "$ip_to_unban" > /dev/null && echo "Successfully released ban" fi done @@ -107,8 +104,8 @@ f2b_unban_ip() { } f2b_ban_an_ip(){ - local ip_to_ban=$1 - local ban_jail=$2 + ip_to_ban=$1 + ban_jail=$2 if [[ ( -z "${ip_to_ban// /}" ) || ( -z "${ban_jail// /}" ) ]]; then echo "Please provide an IP and a Jail (in that order)" @@ -116,5 +113,5 @@ f2b_ban_an_ip(){ return 1 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" } diff --git a/macos/shell/aliases_mac.sh b/macos/shell/aliases_mac.sh index e922658..be17ef4 100644 --- a/macos/shell/aliases_mac.sh +++ b/macos/shell/aliases_mac.sh @@ -2,14 +2,13 @@ # Directories and Directory listings dir_size() { - local dir - if [ -z "$1" ]; then - dir="${PWD}" - else - dir="$1" - fi + if [ "$1" = "" ]; then + dir="$PWD" + else + dir="$1" + fi - du -ah "${dir}" -d 1 | sort -hr + du -ah "$dir" -d 1 | sort -hr } # Update & Upgrades