From 77de585888bec6a0fd4d046db43f4e6a62c004aa Mon Sep 17 00:00:00 2001 From: afonso Date: Wed, 31 Jul 2024 14:22:19 +0100 Subject: [PATCH 1/7] [kitty] added gruvbox --- .config/kitty/current-theme.conf | 95 +++++++++---------------- .config/kitty/kitty.conf | 26 +++---- .config/kitty/kitty.conf.bak | 45 ++++-------- .config/kitty/neighboring_window.py | 9 --- .config/kitty/pass_keys.py | 46 ------------ .config/kitty/themes/gruvbox_dark.conf | 49 +++++++++++++ .config/kitty/themes/gruvbox_light.conf | 49 +++++++++++++ 7 files changed, 153 insertions(+), 166 deletions(-) delete mode 100644 .config/kitty/neighboring_window.py delete mode 100644 .config/kitty/pass_keys.py create mode 100644 .config/kitty/themes/gruvbox_dark.conf create mode 100644 .config/kitty/themes/gruvbox_light.conf diff --git a/.config/kitty/current-theme.conf b/.config/kitty/current-theme.conf index 80c3a35..863e46f 100644 --- a/.config/kitty/current-theme.conf +++ b/.config/kitty/current-theme.conf @@ -1,80 +1,49 @@ -# vim:ft=kitty +# gruvbox dark by morhetz, https://github.com/morhetz/gruvbox +# This work is licensed under the terms of the MIT license. +# For a copy, see https://opensource.org/licenses/MIT. -## name: Catppuccin-Frappe -## author: Pocco81 (https://github.com/Pocco81) -## license: MIT -## upstream: https://github.com/catppuccin/kitty/blob/main/frappe.conf -## blurb: Soothing pastel theme for the high-spirited! +background #1d2021 +foreground #d4be98 +cursor #928374 +selection_foreground #928374 +selection_background #3c3836 -# The basic colors -foreground #C6D0F5 -background #303446 -selection_foreground #303446 -selection_background #F2D5CF - -# Cursor colors -cursor #F2D5CF -cursor_text_color #303446 - -# URL underline color when hovering with mouse -url_color #F2D5CF - -# Kitty window border colors -active_border_color #BABBF1 -inactive_border_color #737994 -bell_border_color #E5C890 - -# OS Window titlebar colors -wayland_titlebar_color system -macos_titlebar_color system - -# Tab bar colors -active_tab_foreground #232634 -active_tab_background #CA9EE6 -inactive_tab_foreground #C6D0F5 -inactive_tab_background #292C3C -tab_bar_background #232634 - -# Colors for marks (marked text in the terminal) -mark1_foreground #303446 -mark1_background #BABBF1 -mark2_foreground #303446 -mark2_background #CA9EE6 -mark3_foreground #303446 -mark3_background #85C1DC - -# The 16 terminal colors - -# black -color0 #51576D -color8 #626880 +color0 #282828 +color8 #928374 # red -color1 #E78284 -color9 #E78284 +color1 #cc241d +# light red +color9 #fb4934 # green -color2 #A6D189 -color10 #A6D189 +color2 #98971a +# light green +color10 #b8bb26 # yellow -color3 #E5C890 -color11 #E5C890 +color3 #d79921 +# light yellow +color11 #fabd2d # blue -color4 #8CAAEE -color12 #8CAAEE +color4 #458588 +# light blue +color12 #83a598 # magenta -color5 #F4B8E4 -color13 #F4B8E4 +color5 #b16286 +# light magenta +color13 #d3869b # cyan -color6 #81C8BE -color14 #81C8BE +color6 #689d6a +# lighy cyan +color14 #8ec07c -# white -color7 #B5BFE2 -color15 #A5ADCE +# light gray +color7 #a89984 +# dark gray +color15 #928374 diff --git a/.config/kitty/kitty.conf b/.config/kitty/kitty.conf index 874cce0..9eb571c 100644 --- a/.config/kitty/kitty.conf +++ b/.config/kitty/kitty.conf @@ -1,25 +1,21 @@ -font_family FiraCode Nerd Font Mono Regular - font_size 16.0 +# Font handling +font_family JetBrainsMono Nerd Font Mono Light +font_size 16.0 +#Remove annoying things enable_audio_bell no -window_padding_width 6 confirm_os_window_close 0 + +# Set TERM env env TERM=xterm-256color + +# Macos stuff macos_option_as_alt yes -background_opacity 0.90 - -hide_window_decorations no - - -#Project management - -#map ctrl+space launch --type=overlay fish -ic "kitty @ ls | jq -r '.[0].tabs | map(.title) | .[]' | fzf | xargs -I _ kitty @ focus-tab --match title:_" - - -include current-theme.conf +# Make it borderless +hide_window_decorations yes # BEGIN_KITTY_THEME -# Catppuccin-Frappe +# Gruvbox Dark include current-theme.conf # END_KITTY_THEME diff --git a/.config/kitty/kitty.conf.bak b/.config/kitty/kitty.conf.bak index 7031695..6dd8855 100644 --- a/.config/kitty/kitty.conf.bak +++ b/.config/kitty/kitty.conf.bak @@ -1,42 +1,21 @@ -font_family FiraCode Nerd Font Mono Normal - font_size 14.0 +# Font handling +font_family JetBrainsMono Nerd Font Mono Light +font_size 16.0 +#Remove annoying things enable_audio_bell no -window_padding_width 6 confirm_os_window_close 0 + +# Set TERM env env TERM=xterm-256color +# Macos stuff +macos_option_as_alt yes - -# Multiplexer mappings -#map ctrl+u kitten pass_keys.py neighboring_window bottom ctrl+u -#map ctrl+i kitten pass_keys.py neighboring_window top ctrl+i -#map ctrl+y kitten pass_keys.py neighboring_window left ctrl+y -#map ctrl+o kitten pass_keys.py neighboring_window right ctrl+o -# -#map ctrl+shift+w no_op -#map ctrl+x close_window -#map ctrl+shift+x close_tab -# -#map ctrl+shift+enter no_op -#map ctrl+n new_window -#map ctrl+shift+n new_tab -# -#map ctrl+f toggle_layout stack -# -# Remote control -#allow_remote_control yes -#listen-on unix:@"$(date +%s%N)" - -#Project management - -#map ctrl+space launch --type=overlay fish -ic "kitty @ ls | jq -r '.[0].tabs | map(.title) | .[]' | fzf | xargs -I _ kitty @ focus-tab --match title:_" - - -include current-theme.conf - +# Make it borderless +hide_window_decorations yes # BEGIN_KITTY_THEME -# Catppuccin-Latte +# Gruvbox Light include current-theme.conf -# END_KITTY_THEME \ No newline at end of file +# END_KITTY_THEME diff --git a/.config/kitty/neighboring_window.py b/.config/kitty/neighboring_window.py deleted file mode 100644 index 4a7ece7..0000000 --- a/.config/kitty/neighboring_window.py +++ /dev/null @@ -1,9 +0,0 @@ -def main(): - pass - - -def handle_result(args, result, target_window_id, boss): - boss.active_tab.neighboring_window(args[1]) - - -handle_result.no_ui = True diff --git a/.config/kitty/pass_keys.py b/.config/kitty/pass_keys.py deleted file mode 100644 index d7cd0c2..0000000 --- a/.config/kitty/pass_keys.py +++ /dev/null @@ -1,46 +0,0 @@ -import re - -from kittens.tui.handler import result_handler -from kitty.key_encoding import KeyEvent, parse_shortcut - - -def is_window_vim(window, vim_id): - fp = window.child.foreground_processes - return any(re.search(vim_id, p['cmdline'][0] if len(p['cmdline']) else '', re.I) for p in fp) - - -def encode_key_mapping(window, key_mapping): - mods, key = parse_shortcut(key_mapping) - event = KeyEvent( - mods=mods, - key=key, - shift=bool(mods & 1), - alt=bool(mods & 2), - ctrl=bool(mods & 4), - super=bool(mods & 8), - hyper=bool(mods & 16), - meta=bool(mods & 32), - ).as_window_system_event() - - return window.encoded_key(event) - - -def main(): - pass - - -@result_handler(no_ui=True) -def handle_result(args, result, target_window_id, boss): - window = boss.window_id_map.get(target_window_id) - direction = args[2] - key_mapping = args[3] - vim_id = args[4] if len(args) > 4 else "n?vim" - - if window is None: - return - if is_window_vim(window, vim_id): - for keymap in key_mapping.split(">"): - encoded = encode_key_mapping(window, keymap) - window.write_to_child(encoded) - else: - boss.active_tab.neighboring_window(direction) diff --git a/.config/kitty/themes/gruvbox_dark.conf b/.config/kitty/themes/gruvbox_dark.conf new file mode 100644 index 0000000..863e46f --- /dev/null +++ b/.config/kitty/themes/gruvbox_dark.conf @@ -0,0 +1,49 @@ +# gruvbox dark by morhetz, https://github.com/morhetz/gruvbox +# This work is licensed under the terms of the MIT license. +# For a copy, see https://opensource.org/licenses/MIT. + +background #1d2021 +foreground #d4be98 + +cursor #928374 + +selection_foreground #928374 +selection_background #3c3836 + +color0 #282828 +color8 #928374 + +# red +color1 #cc241d +# light red +color9 #fb4934 + +# green +color2 #98971a +# light green +color10 #b8bb26 + +# yellow +color3 #d79921 +# light yellow +color11 #fabd2d + +# blue +color4 #458588 +# light blue +color12 #83a598 + +# magenta +color5 #b16286 +# light magenta +color13 #d3869b + +# cyan +color6 #689d6a +# lighy cyan +color14 #8ec07c + +# light gray +color7 #a89984 +# dark gray +color15 #928374 diff --git a/.config/kitty/themes/gruvbox_light.conf b/.config/kitty/themes/gruvbox_light.conf new file mode 100644 index 0000000..6d8b89b --- /dev/null +++ b/.config/kitty/themes/gruvbox_light.conf @@ -0,0 +1,49 @@ +# gruvbox light by morhetz, https://github.com/morhetz/gruvbox +# This work is licensed under the terms of the MIT license. +# For a copy, see https://opensource.org/licenses/MIT. + +background #fbf1c7 +foreground #3c3836 + +cursor #928374 + +selection_foreground #3c3836 +selection_background #928374 + +color0 #fbf1c7 +color8 #282828 + +# red +color1 #cc241d +# light red +color9 #9d0006 + +# green +color2 #98971a +# light green +color10 #79740e + +# yellow +color3 #d79921 +# light yellow +color11 #b57614 + +# blue +color4 #458588 +# light blue +color12 #076678 + +# magenta +color5 #b16286 +# light magenta +color13 #8f3f71 + +# cyan +color6 #689d6a +# lighy cyan +color14 #427b58 + +# light gray +color7 #7c6f64 +# dark gray +color15 #928374 From 7ed2a07221742faf5c7ff9f81f5f7356ba4cadd9 Mon Sep 17 00:00:00 2001 From: afonso Date: Wed, 31 Jul 2024 14:23:19 +0100 Subject: [PATCH 2/7] [nvim] added a few things to config --- .config/nvim/lazy-lock.json | 59 ++++++++++++------------- .config/nvim/lua/plugins/git.lua | 1 + .config/nvim/lua/plugins/lsp.lua | 15 ++++++- .config/nvim/lua/plugins/mini.lua | 25 +++++++++++ .config/nvim/lua/plugins/navigation.lua | 8 ---- 5 files changed, 69 insertions(+), 39 deletions(-) create mode 100644 .config/nvim/lua/plugins/mini.lua diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 5875aa2..6573cb9 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,7 +1,6 @@ { - "LuaSnip": { "branch": "master", "commit": "878ace11983444d865a72e1759dbcc331d1ace4c" }, + "LuaSnip": { "branch": "master", "commit": "ce0a05ab4e2839e1c48d072c5236cce846a387bc" }, "blame.nvim": { "branch": "main", "commit": "dedbcdce857f708c63f261287ac7491a893912d0" }, - "cinnamon.nvim": { "branch": "master", "commit": "a011e84b624cd7b609ea928237505d31b987748a" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, @@ -9,37 +8,37 @@ "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "conform.nvim": { "branch": "master", "commit": "f3b930db4964d60e255c8f9e37b7f2218dfc08cb" }, - "dressing.nvim": { "branch": "master", "commit": "3c38ac861e1b8d4077ff46a779cde17330b29f3a" }, - "friendly-snippets": { "branch": "main", "commit": "d0610077b6129cf9f7f78afbe3a1425d60f6e2f1" }, - "fzf-lua": { "branch": "main", "commit": "b92220ec838c195eb1c711daa69c905b1d7b8d8c" }, - "gruvbox-material": { "branch": "master", "commit": "848b4de6ab014d689d5c20790afebd7c32c1581b" }, + "conform.nvim": { "branch": "master", "commit": "25d48271e3d4404ba017cb92a37d3a681c1ad149" }, + "dressing.nvim": { "branch": "master", "commit": "6741f1062d3dc6e4755367a7e9b347b553623f04" }, + "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, + "fzf-lua": { "branch": "main", "commit": "0c7cd0169cb8433f4f3b102bf6d4c0c7e0a20446" }, + "gruvbox-material": { "branch": "master", "commit": "91f8170a31ae6e31670629cd339df297dbd5fd5f" }, "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" }, - "lazy.nvim": { "branch": "main", "commit": "eab487c2520f0fe9e54eb5e3ea0606e20512492e" }, - "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, - "ltex-extra.nvim": { "branch": "master", "commit": "3ee08af31bf826c6ae2ca2a294b79f688306c0be" }, + "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, + "lspkind.nvim": { "branch": "master", "commit": "cff4ae321a91ee3473a92ea1a8c637e3a9510aec" }, + "ltex-extra.nvim": { "branch": "master", "commit": "24acd044ce7a26b3cdb537cbd094de37c3e1ac45" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "a4caa0d083aab56f6cd5acf2d42331b74614a585" }, - "mason.nvim": { "branch": "main", "commit": "0fb4e56837f13b81a972fcc0554be1327b39061e" }, - "mini.ai": { "branch": "main", "commit": "7859b6344f5cee567a94f173859d25e20ba1a77e" }, - "mini.notify": { "branch": "main", "commit": "2d506633f50bd61b1041aa4a6d62e0fe0e6ae09e" }, - "nvim-autopairs": { "branch": "master", "commit": "c15de7e7981f1111642e7e53799e1211d4606cb9" }, - "nvim-bqf": { "branch": "main", "commit": "7751b6ef9fbc3907478eaf23e866c4316a2ed1b4" }, - "nvim-cmp": { "branch": "main", "commit": "5260e5e8ecadaf13e6b82cf867a909f54e15fd07" }, - "nvim-lspconfig": { "branch": "master", "commit": "710a8fa7379db32199545f30ea01dd8446b9302f" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "ba9c2f0b93deb48d0a99ae0e8d8dd36f7cc286d6" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "mini.ai": { "branch": "main", "commit": "45587078f323eaf41b9f701bbc04f8d1ab008979" }, + "mini.notify": { "branch": "main", "commit": "a6101a5fa7eff7bdfbfc887ad9a331305729f0ec" }, + "nvim-autopairs": { "branch": "master", "commit": "e38c5d837e755ce186ae51d2c48e1b387c4425c6" }, + "nvim-bqf": { "branch": "main", "commit": "1b24dc6050c34e8cd377b6b4cd6abe40509e0187" }, + "nvim-cmp": { "branch": "main", "commit": "d818fd0624205b34e14888358037fb6f5dc51234" }, + "nvim-lspconfig": { "branch": "master", "commit": "fdc44768a09a65140aa00c92872a5381ad486485" }, "nvim-tmux-navigation": { "branch": "main", "commit": "4898c98702954439233fdaf764c39636681e2861" }, - "nvim-treesitter": { "branch": "master", "commit": "b7d50e59b1b2990b3ce8761d4cf595f4b71c87e2" }, - "nvim-treesitter-context": { "branch": "master", "commit": "f62bfe19e0fbc13ae95649dfb3cf22f4ff85b683" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "3557e41418b4a6c5b85d5d64abe94c9c50fa9b14" }, - "nvim-web-devicons": { "branch": "master", "commit": "b77921fdc44833c994fdb389d658ccbce5490c16" }, - "oil.nvim": { "branch": "master", "commit": "2cb39e838e9dcd8b374f09a3a87a2e5ec9d372f6" }, - "pastify.nvim": { "branch": "main", "commit": "47317b9bb7bf5fb7dfd994a6eb9bec8f00628dc0" }, + "nvim-treesitter": { "branch": "master", "commit": "a7ba147b4b51631f7cf7d9da56f7d5763073b18d" }, + "nvim-treesitter-context": { "branch": "master", "commit": "2aba92ceb1479485953007f4d5adf34d0b66917e" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, + "nvim-web-devicons": { "branch": "master", "commit": "5be6c4e685618b99c3210a69375b38a1202369b4" }, + "oil.nvim": { "branch": "master", "commit": "71c972fbd218723a3c15afcb70421f67340f5a6d" }, + "pastify.nvim": { "branch": "main", "commit": "65cb31402b44f0ff52f9ff49a60d15732e6e1851" }, "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, - "todo-comments.nvim": { "branch": "main", "commit": "e1549807066947818113a7d7ed48f637e49620d3" }, + "rustaceanvim": { "branch": "master", "commit": "047f9c9d8cd2861745eb9de6c1570ee0875aa795" }, + "todo-comments.nvim": { "branch": "main", "commit": "8f45f353dc3649cb9b44cecda96827ea88128584" }, "undotree": { "branch": "master", "commit": "56c684a805fe948936cda0d1b19505b84ad7e065" }, "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, - "vim-tpipeline": { "branch": "master", "commit": "5dd3832bd6e239feccb11cadca583cdcf9d5bda1" }, - "vim-visual-multi": { "branch": "master", "commit": "b84a6d42c1c10678928b0bf8327f378c8bc8af5a" }, - "vimtex": { "branch": "master", "commit": "9665df7f51ee24aa81dbd81782e0a22480209753" }, - "zen-mode.nvim": { "branch": "main", "commit": "78557d972b4bfbb7488e17b5703d25164ae64e6a" } -} \ No newline at end of file + "vim-tpipeline": { "branch": "master", "commit": "f59f144b73e79aae7a73bb86bf527e79ad86de8f" }, + "vimtex": { "branch": "master", "commit": "5ac62e0315c6f54f53a7d6da7c485cf8e9cf7240" }, + "zen-mode.nvim": { "branch": "main", "commit": "29b292bdc58b76a6c8f294c961a8bf92c5a6ebd6" } +} diff --git a/.config/nvim/lua/plugins/git.lua b/.config/nvim/lua/plugins/git.lua index a6dbe7b..1d86548 100644 --- a/.config/nvim/lua/plugins/git.lua +++ b/.config/nvim/lua/plugins/git.lua @@ -6,4 +6,5 @@ return { require("blame").setup() end }, + } diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index 02d2825..aeb8875 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -111,7 +111,10 @@ return { end, settings = { ltex = { - language = "pt-PT", + language = "en-GB", + }, + additionalRules = { + enablePickyRules = true, }, }, }) @@ -190,8 +193,17 @@ return { capabilities = capabilities, filetypes = { 'haskell', 'lhaskell', 'cabal' }, }) + + lspconfig["sourcekit"].setup({ + capabilities = capabilities, + }) end, }, + { + 'mrcjkb/rustaceanvim', + version = '^4', -- Recommended + lazy = false, -- This plugin is already lazy + }, { "stevearc/conform.nvim", event = "VeryLazy", @@ -202,6 +214,7 @@ return { haskell = { "fourmolu" }, javascript = { "prettierd" }, markdown = { "mdformat" }, + rust = { "rustfmt" }, go = { "gofmt" }, json = { "jq" } } diff --git a/.config/nvim/lua/plugins/mini.lua b/.config/nvim/lua/plugins/mini.lua new file mode 100644 index 0000000..3f39ac0 --- /dev/null +++ b/.config/nvim/lua/plugins/mini.lua @@ -0,0 +1,25 @@ +return { + { + 'echasnovski/mini.ai', + version = false, + opts = {} + }, + + { + 'echasnovski/mini.notify', + version = false, + config = function() + vim.api.nvim_set_hl(0, 'MiniNotifyNormal', { link = 'Normal' }) + vim.api.nvim_set_hl(0, 'MiniNotifyBorder', { link = 'Normal' }) + require("mini.notify").setup({ + -- Window options + window = { + -- Floating window config + config = {}, + -- Value of 'winblend' option + }, + + }) + end + }, +} diff --git a/.config/nvim/lua/plugins/navigation.lua b/.config/nvim/lua/plugins/navigation.lua index d8c38f9..8c67595 100644 --- a/.config/nvim/lua/plugins/navigation.lua +++ b/.config/nvim/lua/plugins/navigation.lua @@ -33,12 +33,4 @@ return { }, }, }, - { - "declancm/cinnamon.nvim", - event = "VeryLazy", - opts = { - scroll_limit = 10000, - always_scroll = true, - }, - }, } From 5e695cebd7da584994b0f49919b1f2cbdd71d16b Mon Sep 17 00:00:00 2001 From: afonso Date: Wed, 31 Jul 2024 14:23:38 +0100 Subject: [PATCH 3/7] [skhd] replaced alacritty with kitty --- .config/skhd/skhdrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/skhd/skhdrc b/.config/skhd/skhdrc index ddc6201..8629d21 100644 --- a/.config/skhd/skhdrc +++ b/.config/skhd/skhdrc @@ -1,5 +1,5 @@ # Terminal and Applications -cmd + alt - t : open -na alacritty +cmd + alt - t : open -na kitty cmd + alt - b : open -a Firefox cmd + shift - v : ~/.config/skhd/scripts/menubar.sh From 3cb8cae14cfdfba44a9e0210384ce4c9a0fcc202 Mon Sep 17 00:00:00 2001 From: afonso Date: Wed, 31 Jul 2024 14:24:06 +0100 Subject: [PATCH 4/7] [tmux] increased floating window size for lazygit --- .config/tmux/tmux_binds.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/tmux/tmux_binds.conf b/.config/tmux/tmux_binds.conf index 5a7af34..f2ffeb4 100644 --- a/.config/tmux/tmux_binds.conf +++ b/.config/tmux/tmux_binds.conf @@ -29,4 +29,4 @@ bind-key 's' display-popup -E -w 90% -h 90% "~/.local/bin/tms" #Lazygit unbind g -bind-key 'g' display-popup -d '#{pane_current_path}' -E -w 90% -h 90% "lazygit" +bind-key 'g' display-popup -d '#{pane_current_path}' -E -w 95% -h 95% "lazygit" From 59e4ce27de81084ee95b16e70db2a5b0964e022e Mon Sep 17 00:00:00 2001 From: afonso Date: Wed, 31 Jul 2024 14:25:01 +0100 Subject: [PATCH 5/7] [zsh] added tmux plugin, cleaned git plugin and themes --- .config/zsh-abbr/user-abbreviations | 3 - .config/zsh/.zshrc | 18 +-- .config/zsh/dotfiles.zsh | 5 - .config/zsh/main.zsh | 23 --- .config/zsh/overrides.zsh | 9 -- .config/zsh/plugins.zsh | 6 +- .config/zsh/plugins/zsh-git.plugin.zsh | 178 +-------------------- .config/zsh/plugins/zsh-tmux.plugins.zsh | 190 +++++++++++++++++++++++ .config/zsh/qol.zsh | 29 ---- .config/zsh/replacements.zsh | 19 --- .config/zsh/themes/gruvbox_light.zsh | 2 + 11 files changed, 209 insertions(+), 273 deletions(-) delete mode 100644 .config/zsh-abbr/user-abbreviations delete mode 100644 .config/zsh/dotfiles.zsh delete mode 100644 .config/zsh/main.zsh delete mode 100644 .config/zsh/overrides.zsh create mode 100644 .config/zsh/plugins/zsh-tmux.plugins.zsh delete mode 100644 .config/zsh/qol.zsh delete mode 100644 .config/zsh/replacements.zsh diff --git a/.config/zsh-abbr/user-abbreviations b/.config/zsh-abbr/user-abbreviations deleted file mode 100644 index 12f7ed0..0000000 --- a/.config/zsh-abbr/user-abbreviations +++ /dev/null @@ -1,3 +0,0 @@ -abbr "i"="sudo pacman -S" -abbr "r"="sudo pacman -Rns" -abbr "s"="sudo pacman -Ss" diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 0f1f6e5..fceb744 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -28,7 +28,6 @@ setopt HIST_SAVE_NO_DUPS setopt HIST_IGNORE_ALL_DUPS setopt HIST_VERIFY - #Set EDITOR AND READER export EDITOR=nvim export VISUAL=nvim @@ -46,28 +45,25 @@ fpath+=$ZDOTDIR/prompts/pure autoload -U promptinit; promptinit prompt pure -source $ZDOTDIR/dotfiles.zsh -source $ZDOTDIR/qol.zsh -source $ZDOTDIR/replacements.zsh -source $ZDOTDIR/overrides.zsh +source $ZDOTDIR/functions.zsh source $ZDOTDIR/plugins.zsh # >>> conda initialize >>> # !! Contents within this block are managed by 'conda init' !! -__conda_setup="$('/Users/afonso/.miniforge3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)" +__conda_setup="$('$HOME/.miniforge3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)" if [ $? -eq 0 ]; then eval "$__conda_setup" else - if [ -f "/Users/afonso/.miniforge3/etc/profile.d/conda.sh" ]; then - . "/Users/afonso/.miniforge3/etc/profile.d/conda.sh" + if [ -f "$HOME/.miniforge3/etc/profile.d/conda.sh" ]; then + . "$HOME/.miniforge3/etc/profile.d/conda.sh" else - export PATH="/Users/afonso/.miniforge3/bin:$PATH" + export PATH="$HOME/.miniforge3/bin:$PATH" fi fi unset __conda_setup -if [ -f "/Users/afonso/.miniforge3/etc/profile.d/mamba.sh" ]; then - . "/Users/afonso/.miniforge3/etc/profile.d/mamba.sh" +if [ -f "$HOME/.miniforge3/etc/profile.d/mamba.sh" ]; then + . "$HOME/.miniforge3/etc/profile.d/mamba.sh" fi # <<< conda initialize <<< diff --git a/.config/zsh/dotfiles.zsh b/.config/zsh/dotfiles.zsh deleted file mode 100644 index 257fe78..0000000 --- a/.config/zsh/dotfiles.zsh +++ /dev/null @@ -1,5 +0,0 @@ -# ~/.config/zsh/myfunctions/dotfiles.zsh - -alias config="/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME" - -alias lc="lazygit --git-dir=$HOME/dotfiles/ --work-tree=$HOME/" diff --git a/.config/zsh/main.zsh b/.config/zsh/main.zsh deleted file mode 100644 index 57c343c..0000000 --- a/.config/zsh/main.zsh +++ /dev/null @@ -1,23 +0,0 @@ - -HISTSIZE=100000000 -SAVEHIST=100000000 -setopt BANG_HIST # Treat the '!' character specially during expansion. -setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format. -setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits. -setopt SHARE_HISTORY # Share history between all sessions. -setopt HIST_FIND_NO_DUPS # Do not display a line previously found. -setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space. -setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry. -setopt HIST_SAVE_NO_DUPS -setopt HIST_VERIFY - -export EDITOR=nvim -export VISUAL=nvim -export READER=mupdf - -enable-fzf-tab - -eval "$(direnv hook zsh)" -if [[ $(uname) == "Darwin" ]]; then - eval "$(/opt/homebrew/bin/brew shellenv)" -fi diff --git a/.config/zsh/overrides.zsh b/.config/zsh/overrides.zsh deleted file mode 100644 index 7433e46..0000000 --- a/.config/zsh/overrides.zsh +++ /dev/null @@ -1,9 +0,0 @@ -ZSH_AUTOSUGGEST_STRATEGY=(match_prev_cmd history completion) - -if [[ ! $(tty) =~ ^/dev/tty[0-9]*$ ]]; then - if [[ -z $TMUX ]]; then - tmux new -As0 - fi -fi - -zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath' diff --git a/.config/zsh/plugins.zsh b/.config/zsh/plugins.zsh index 65a8887..5ff8cf3 100644 --- a/.config/zsh/plugins.zsh +++ b/.config/zsh/plugins.zsh @@ -1,17 +1,21 @@ +ZSH_AUTOSUGGEST_STRATEGY=(match_prev_cmd history completion) source $ZDOTDIR/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh source $ZDOTDIR/plugins/zsh-history-substring-search/zsh-history-substring-search.plugin.zsh source $ZDOTDIR/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh +zvm_after_init_commands+=('[ -f $HOME/.fzf.zsh ] && source $HOME/.fzf.zsh') source $ZDOTDIR/plugins/fzf-tab/fzf-tab.plugin.zsh +zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath' enable-fzf-tab source $ZDOTDIR/plugins/zsh-vi-mode/zsh-vi-mode.plugin.zsh -zvm_after_init_commands+=('[ -f $HOME/.fzf.zsh ] && source $HOME/.fzf.zsh') source $ZDOTDIR/plugins/zsh-macos.plugin.zsh source $ZDOTDIR/plugins/zsh-git.plugin.zsh source $ZDOTDIR/plugins/zsh-sudo.plugins.zsh + +source $ZDOTDIR/plugins/zsh-tmux.plugins.zsh diff --git a/.config/zsh/plugins/zsh-git.plugin.zsh b/.config/zsh/plugins/zsh-git.plugin.zsh index 7f87511..3452f14 100644 --- a/.config/zsh/plugins/zsh-git.plugin.zsh +++ b/.config/zsh/plugins/zsh-git.plugin.zsh @@ -102,31 +102,9 @@ compdef _git ggpnp=git-checkout alias ggpur='ggu' alias g='git' -alias ga='git add' alias gaa='git add --all' -alias gapa='git add --patch' -alias gau='git add --update' -alias gav='git add --verbose' -alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"' -alias gam='git am' -alias gama='git am --abort' -alias gamc='git am --continue' -alias gamscp='git am --show-current-patch' -alias gams='git am --skip' -alias gap='git apply' -alias gapt='git apply --3way' -alias gbs='git bisect' -alias gbsb='git bisect bad' -alias gbsg='git bisect good' -alias gbsn='git bisect new' -alias gbso='git bisect old' -alias gbsr='git bisect reset' -alias gbss='git bisect start' -alias gbl='git blame -w' alias gb='git branch' -alias gba='git branch --all' alias gbd='git branch --delete' -alias gbD='git branch --delete --force' function gbda() { git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch --delete 2>/dev/null @@ -147,25 +125,9 @@ function gbds() { done } -alias gbgd='LANG=C git branch --no-color -vv | grep ": gone\]" | cut -c 3- | awk '"'"'{print $1}'"'"' | xargs git branch -d' -alias gbgD='LANG=C git branch --no-color -vv | grep ": gone\]" | cut -c 3- | awk '"'"'{print $1}'"'"' | xargs git branch -D' -alias gbm='git branch --move' -alias gbnm='git branch --no-merged' -alias gbr='git branch --remote' -alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' -alias gbg='LANG=C git branch -vv | grep ": gone\]"' -alias gco='git checkout' -alias gcor='git checkout --recurse-submodules' alias gcb='git checkout -b' -alias gcB='git checkout -B' -alias gcd='git checkout $(git_develop_branch)' alias gcm='git checkout $(git_main_branch)' -alias gcp='git cherry-pick' -alias gcpa='git cherry-pick --abort' -alias gcpc='git cherry-pick --continue' -alias gclean='git clean --interactive -d' alias gcl='git clone --recurse-submodules' -alias gclf='git clone --recursive --shallow-submodules --filter=blob:none --also-filter-submodules' function gccd() { setopt localoptions extendedglob @@ -183,28 +145,7 @@ function gccd() { compdef _git gccd=git-clone alias gcam='git commit --all --message' -alias gcas='git commit --all --signoff' -alias gcasm='git commit --all --signoff --message' -alias gcs='git commit --gpg-sign' -alias gcss='git commit --gpg-sign --signoff' -alias gcssm='git commit --gpg-sign --signoff --message' -alias gcmsg='git commit --message' -alias gcsm='git commit --signoff --message' -alias gc='git commit --verbose' -alias gca='git commit --verbose --all' -alias gca!='git commit --verbose --all --amend' -alias gcan!='git commit --verbose --all --no-edit --amend' -alias gcans!='git commit --verbose --all --signoff --no-edit --amend' -alias gcann!='git commit --verbose --all --date=now --no-edit --amend' -alias gc!='git commit --verbose --amend' -alias gcn!='git commit --verbose --no-edit --amend' -alias gcf='git config --list' -alias gdct='git describe --tags $(git rev-list --tags --max-count=1)' alias gd='git diff' -alias gdca='git diff --cached' -alias gdcw='git diff --cached --word-diff' -alias gds='git diff --staged' -alias gdw='git diff --word-diff' function gdv() { git diff -w "$@" | view - } compdef _git gdv=git-diff @@ -216,27 +157,8 @@ function gdnolock() { } compdef _git gdnolock=git-diff -alias gdt='git diff-tree --no-commit-id --name-only -r' alias gf='git fetch' -# --jobs= was added in git 2.8 -is-at-least 2.8 "$git_version" \ - && alias gfa='git fetch --all --prune --jobs=10' \ - || alias gfa='git fetch --all --prune' -alias gfo='git fetch origin' -alias gg='git gui citool' -alias gga='git gui citool --amend' -alias ghh='git help' -alias glgg='git log --graph' -alias glgga='git log --graph --decorate --all' -alias glgm='git log --graph --max-count=10' -alias glods='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset" --date=short' -alias glod='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset"' -alias glola='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --all' -alias glols='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --stat' alias glol='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset"' -alias glo='git log --oneline --decorate' -alias glog='git log --oneline --decorate --graph' -alias gloga='git log --oneline --decorate --graph --all' # Pretty log messages function _git_log_prettily(){ @@ -246,25 +168,10 @@ function _git_log_prettily(){ } compdef _git _git_log_prettily=git-log -alias glp='_git_log_prettily' -alias glg='git log --stat' -alias glgp='git log --stat --patch' -alias gignored='git ls-files -v | grep "^[[:lower:]]"' -alias gfg='git ls-files | grep' alias gm='git merge' alias gma='git merge --abort' -alias gmc='git merge --continue' -alias gms="git merge --squash" -alias gmom='git merge origin/$(git_main_branch)' -alias gmum='git merge upstream/$(git_main_branch)' -alias gmtl='git mergetool --no-prompt' -alias gmtlvim='git mergetool --no-prompt --tool=vimdiff' alias gl='git pull' -alias gpr='git pull --rebase' -alias gprv='git pull --rebase -v' -alias gpra='git pull --rebase --autostash' -alias gprav='git pull --rebase --autostash -v' function ggu() { [[ "$#" != 1 ]] && local b="$(git_current_branch)" @@ -272,8 +179,6 @@ function ggu() { } compdef _git ggu=git-checkout -alias gprom='git pull --rebase origin $(git_main_branch)' -alias gpromi='git pull --rebase=interactive origin $(git_main_branch)' alias ggpull='git pull origin "$(git_current_branch)"' function ggl() { @@ -286,10 +191,7 @@ function ggl() { } compdef _git ggl=git-checkout -alias gluc='git pull upstream $(git_current_branch)' -alias glum='git pull upstream $(git_main_branch)' alias gp='git push' -alias gpd='git push --dry-run' function ggf() { [[ "$#" != 1 ]] && local b="$(git_current_branch)" @@ -308,13 +210,6 @@ function ggfl() { } compdef _git ggfl=git-checkout -alias gpsup='git push --set-upstream origin $(git_current_branch)' -is-at-least 2.30 "$git_version" \ - && alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes' \ - || alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease' -alias gpv='git push --verbose' -alias gpoat='git push origin --all && git push origin --tags' -alias gpod='git push origin --delete' alias ggpush='git push origin "$(git_current_branch)"' function ggp() { @@ -328,81 +223,18 @@ function ggp() { compdef _git ggp=git-checkout alias gpu='git push upstream' -alias grb='git rebase' -alias grba='git rebase --abort' -alias grbc='git rebase --continue' -alias grbi='git rebase --interactive' -alias grbo='git rebase --onto' -alias grbs='git rebase --skip' -alias grbd='git rebase $(git_develop_branch)' -alias grbm='git rebase $(git_main_branch)' -alias grbom='git rebase origin/$(git_main_branch)' -alias grf='git reflog' -alias gr='git remote' -alias grv='git remote --verbose' alias gra='git remote add' -alias grrm='git remote remove' -alias grmv='git remote rename' -alias grset='git remote set-url' -alias grup='git remote update' -alias grh='git reset' -alias gru='git reset --' alias grhh='git reset --hard' -alias grhk='git reset --keep' -alias grhs='git reset --soft' alias gpristine='git reset --hard && git clean --force -dfx' -alias gwipe='git reset --hard && git clean --force -df' -alias groh='git reset origin/$(git_current_branch) --hard' -alias grs='git restore' -alias grss='git restore --source' -alias grst='git restore --staged' -alias gunwip='git rev-list --max-count=1 --format="%s" HEAD | grep -q "\--wip--" && git reset HEAD~1' -alias grev='git revert' -alias greva='git revert --abort' -alias grevc='git revert --continue' alias grm='git rm' -alias grmc='git rm --cached' -alias gcount='git shortlog --summary --numbered' -alias gsh='git show' alias gsps='git show --pretty=short --show-signature' -alias gstall='git stash --all' -alias gstaa='git stash apply' -alias gstc='git stash clear' -alias gstd='git stash drop' -alias gstl='git stash list' -alias gstp='git stash pop' -# use the default stash push on git 2.13 and newer -is-at-least 2.13 "$git_version" \ - && alias gsta='git stash push' \ - || alias gsta='git stash save' -alias gsts='git stash show --patch' alias gst='git status' -alias gss='git status --short' -alias gsb='git status --short --branch' -alias gsi='git submodule init' -alias gsu='git submodule update' -alias gsd='git svn dcommit' -alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk' -alias gsr='git svn rebase' alias gsw='git switch' -alias gswc='git switch --create' -alias gswd='git switch $(git_develop_branch)' -alias gswm='git switch $(git_main_branch)' -alias gta='git tag --annotate' -alias gts='git tag --sign' -alias gtv='git tag | sort -V' -alias gignore='git update-index --assume-unchanged' -alias gunignore='git update-index --no-assume-unchanged' -alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' -alias gwt='git worktree' -alias gwta='git worktree add' -alias gwtls='git worktree list' -alias gwtmv='git worktree move' -alias gwtrm='git worktree remove' -alias gstu='gsta --include-untracked' -alias gtl='gtl(){ git tag --sort=-v:refname -n --list "${1}*" }; noglob gtl' -alias gk='\gitk --all --branches &!' -alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h) &!' + +function gcpr(){ + git fetch -fu upstream refs/pull/$1/head:pr/$1 + git checkout pr/$1 +} unset git_version diff --git a/.config/zsh/plugins/zsh-tmux.plugins.zsh b/.config/zsh/plugins/zsh-tmux.plugins.zsh new file mode 100644 index 0000000..1050e52 --- /dev/null +++ b/.config/zsh/plugins/zsh-tmux.plugins.zsh @@ -0,0 +1,190 @@ +if ! (( $+commands[tmux] )); then + print "zsh tmux plugin: tmux not found. Please install tmux before using this plugin." >&2 + return 1 +fi + +# CONFIGURATION VARIABLES +# Automatically start tmux +if [[ ! $(tty) =~ ^/dev/tty[0-9]*$ ]]; then + : ${ZSH_TMUX_AUTOSTART:=true} +else + : ${ZSH_TMUX_AUTOSTART:=false} +fi +# Only autostart once. If set to false, tmux will attempt to +# autostart every time your zsh configs are reloaded. +: ${ZSH_TMUX_AUTOSTART_ONCE:=true} +# Automatically connect to a previous session if it exists +: ${ZSH_TMUX_AUTOCONNECT:=true} +# Automatically close the terminal when tmux exits +: ${ZSH_TMUX_AUTOQUIT:=false} +# Automatically name the new session based on the basename of PWD +: ${ZSH_TMUX_AUTONAME_SESSION:=false} +# Set term to screen or screen-256color based on current terminal support +: ${ZSH_TMUX_DETACHED:=false} +# Set detached mode +: ${ZSH_TMUX_FIXTERM:=true} +# Set '-CC' option for iTerm2 tmux integration +: ${ZSH_TMUX_ITERM2:=false} +# The TERM to use for non-256 color terminals. +# Tmux states this should be tmux|screen, but you may need to change it on +# systems without the proper terminfo +if [[ -e /usr/share/terminfo/t/tmux ]]; then + : ${ZSH_TMUX_FIXTERM_WITHOUT_256COLOR:=tmux} +else + : ${ZSH_TMUX_FIXTERM_WITHOUT_256COLOR:=screen} +fi +# The TERM to use for 256 color terminals. +# Tmux states this should be (tmux|screen)-256color, but you may need to change it on +# systems without the proper terminfo +if [[ -e /usr/share/terminfo/t/tmux-256color ]]; then + : ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=tmux-256color} +else + : ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color} +fi +# Set the configuration path +if [[ -e $HOME/.tmux.conf ]]; then + : ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf} +elif [[ -e ${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf ]]; then + : ${ZSH_TMUX_CONFIG:=${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf} +else + : ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf} +fi +# Set -u option to support unicode +: ${ZSH_TMUX_UNICODE:=false} + +# ALIASES +function _build_tmux_alias { + setopt localoptions no_rc_expand_param + eval "function $1 { + if [[ -z \$1 ]] || [[ \${1:0:1} == '-' ]]; then + tmux $2 \"\$@\" + else + tmux $2 $3 \"\$@\" + fi + }" + + local f s + f="_omz_tmux_alias_${1}" + s=(${(z)2}) + + eval "function ${f}() { + shift words; + words=(tmux ${@:2} \$words); + ((CURRENT+=${#s[@]}+1)) + _tmux + }" + + compdef "$f" "$1" +} + +alias tksv='tmux kill-server' +alias tl='tmux list-sessions' +alias tmuxconf='$EDITOR $ZSH_TMUX_CONFIG' + +_build_tmux_alias "ta" "attach" "-t" +_build_tmux_alias "tad" "attach -d" "-t" +_build_tmux_alias "ts" "new-session" "-s" +_build_tmux_alias "tkss" "kill-session" "-t" + +unfunction _build_tmux_alias + +# Determine if the terminal supports 256 colors +if [[ $terminfo[colors] == 256 ]]; then + export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR +else + export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR +fi + +# Handle $0 according to the standard: +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" +0="${${(M)0:#/*}:-$PWD/$0}" + +# Set the correct local config file to use. +if [[ "$ZSH_TMUX_ITERM2" == "false" && -e "$ZSH_TMUX_CONFIG" ]]; then + export ZSH_TMUX_CONFIG + export _ZSH_TMUX_FIXED_CONFIG="${0:h:a}/tmux.extra.conf" +else + export _ZSH_TMUX_FIXED_CONFIG="${0:h:a}/tmux.only.conf" +fi + +# Wrapper function for tmux. +function _zsh_tmux_plugin_run() { + if [[ -n "$@" ]]; then + command tmux "$@" + return $? + fi + + local -a tmux_cmd + tmux_cmd=(command tmux) + [[ "$ZSH_TMUX_ITERM2" == "true" ]] && tmux_cmd+=(-CC) + [[ "$ZSH_TMUX_UNICODE" == "true" ]] && tmux_cmd+=(-u) + + local _detached="" + [[ "$ZSH_TMUX_DETACHED" == "true" ]] && _detached="-d" + + local session_name + if [[ "$ZSH_TMUX_AUTONAME_SESSION" == "true" ]]; then + # Name the session after the basename of the current directory + session_name=${PWD##*/} + # If the current directory is the home directory, name it 'HOME' + [[ "$PWD" == "$HOME" ]] && session_name="HOME" + # If the current directory is the root directory, name it 'ROOT' + [[ "$PWD" == "/" ]] && session_name="ROOT" + else + session_name="$ZSH_TMUX_DEFAULT_SESSION_NAME" + fi + + # Try to connect to an existing session. + if [[ -n "$session_name" ]]; then + [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached -t "$session_name" + else + [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached + fi + + # If failed, just run tmux, fixing the TERM variable if requested. + if [[ $? -ne 0 ]]; then + if [[ "$ZSH_TMUX_FIXTERM" == "true" ]]; then + tmux_cmd+=(-f "$_ZSH_TMUX_FIXED_CONFIG") + elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then + tmux_cmd+=(-f "$ZSH_TMUX_CONFIG") + fi + + if [[ -n "$session_name" ]]; then + $tmux_cmd new-session -s "$session_name" + else + $tmux_cmd new-session + fi + fi + + if [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]]; then + exit + fi +} + +# Use the completions for tmux for our function +compdef _tmux _zsh_tmux_plugin_run +# Alias tmux to our wrapper function. +alias tmux=_zsh_tmux_plugin_run + +function _tmux_directory_session() { + # current directory without leading path + local dir=${PWD##*/} + # md5 hash for the full working directory path + local md5=$(printf '%s' "$PWD" | md5sum | cut -d ' ' -f 1) + # human friendly unique session name for this directory + local session_name="${dir}-${md5:0:6}" + # create or attach to the session + tmux new -As "$session_name" +} + +alias tds=_tmux_directory_session + +# Autostart if not already in tmux and enabled. +if [[ -z "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" && -z "$INSIDE_EMACS" && -z "$EMACS" && -z "$VIM" && -z "$INTELLIJ_ENVIRONMENT_READER" ]]; then + # Actually don't autostart if we already did and multiple autostarts are disabled. + if [[ "$ZSH_TMUX_AUTOSTART_ONCE" == "false" || "$ZSH_TMUX_AUTOSTARTED" != "true" ]]; then + export ZSH_TMUX_AUTOSTARTED=true + _zsh_tmux_plugin_run + fi +fi diff --git a/.config/zsh/qol.zsh b/.config/zsh/qol.zsh deleted file mode 100644 index 2f88d87..0000000 --- a/.config/zsh/qol.zsh +++ /dev/null @@ -1,29 +0,0 @@ -# ~/.config/zsh/qol.zsh - -backup() { - cp $1 $1.bak -} - -restore() { - mv $1 $(echo $1 | sed 's/\.bak//') -} - -capture() { - sudo dtrace -p "$1" -qn ' - syscall::write*:entry - /pid == $target && arg0 == 1/ { - printf("%s", copyinstr(arg1, arg2)); - } - ' -} - -sourceall(){ - set -e - pids=$(pgrep zsh) - while IFS= read -r pid; do - kill -USR1 "$pid" - done <<< "$pids" - set +e -} - -alias routes="netstat -rn -f inet" diff --git a/.config/zsh/replacements.zsh b/.config/zsh/replacements.zsh deleted file mode 100644 index 808cf08..0000000 --- a/.config/zsh/replacements.zsh +++ /dev/null @@ -1,19 +0,0 @@ -# ~/.config/zsh/replacements.zsh - -alias ls="eza --icons -l --sort type" - -function vim { - if [[ -z "$@" ]]; then - if [[ -f "./.session.vim" ]]; then - nvim -S .session.vim --listen /tmp/nvim.pipe -c 'lua vim.g.savesession = true' - else - nvim --listen /tmp/nvim.pipe -c 'lua vim.g.savesession = true' - fi - else - nvim --listen /tmp/nvim.pipe "$@" - fi -} - - -alias lg="lazygit" -alias calcurse-caldav='CALCURSE_CALDAV_PASSWORD=$(keyring get caldav afonso) calcurse-caldav' diff --git a/.config/zsh/themes/gruvbox_light.zsh b/.config/zsh/themes/gruvbox_light.zsh index 36f6c7e..5a0c624 100644 --- a/.config/zsh/themes/gruvbox_light.zsh +++ b/.config/zsh/themes/gruvbox_light.zsh @@ -134,6 +134,8 @@ export FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS"\ " --color=fg:$color04,header:$color0D,info:$color0A,pointer:$color0C"\ " --color=marker:$color0C,fg+:$color06,prompt:$color0A,hl+:$color0D" +zstyle ":fzf-tab:*" fzf-flags + } _gen_fzf_default_opts From db0658c0f5c7e5cc93126981293aa9c972f70449 Mon Sep 17 00:00:00 2001 From: afonso Date: Wed, 31 Jul 2024 14:25:20 +0100 Subject: [PATCH 6/7] [scripts] added kitty to change-theme.sh --- .local/bin/change-theme.sh | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.local/bin/change-theme.sh b/.local/bin/change-theme.sh index 406d570..772099c 100755 --- a/.local/bin/change-theme.sh +++ b/.local/bin/change-theme.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/zsh # Required parameters: # @raycast.schemaVersion 1 @@ -7,7 +7,9 @@ # @raycast.argument1 { "type": "dropdown","placeholder":"Theme", "data": [{"title": "Catppuccin Frappe", "value": "catppuccin-frappe"},{"title": "Catppuccin Latte", "value": "catppuccin-latte"},{"title": "Gruvbox Dark", "value": "gruvbox-dark"},{"title": "Gruvbox Light", "value": "gruvbox-light"}]} # -alacritty_theme_name="" +#Ignore errors +set +e +terminal_theme_name="" zsh_theme_name="" background_color="" nvim_color_scheme="" @@ -17,9 +19,9 @@ tmux_bar_focused_fg="" change_common(){ #Change alacritty theme - sed -i '' -e "s|import = \[\"~/.config/alacritty/themes/.*\"\]|import = [\"~/.config/alacritty/themes/${alacritty_theme_name}.toml\"]|g" ~/.config/alacritty/alacritty.toml + sed -i '' -e "s|import = \[\"~/.config/alacritty/themes/.*\"\]|import = [\"~/.config/alacritty/themes/${terminal_theme_name}.toml\"]|g" ~/.config/alacritty/alacritty.toml #Change zsh theme - sed -i '' -e "s|source \$ZDOTDIR/themes/.*zsh|source \$ZDOTDIR/themes/${zsh_theme_name}.zsh|g" ~/.zshrc + sed -i '' -e "s|source \$ZDOTDIR/themes/.*zsh|source \$ZDOTDIR/themes/${zsh_theme_name}.zsh|g" "$ZDOTDIR"/.zshrc #Reload zsh sessions pids=$(pgrep zsh) while IFS= read -r pid; do @@ -42,7 +44,7 @@ change_common(){ case $1 in "catppuccin-latte") - alacritty_theme_name="catppuccin_latte" + terminal_theme_name="catppuccin_latte" zsh_theme_name="catppuccin_latte" nvim_color_scheme="catppuccin-latte" background_color="#eff1f5" @@ -55,7 +57,7 @@ case $1 in ;; "catppuccin-frappe") - alacritty_theme_name="catppuccin_frappe" + terminal_theme_name="catppuccin_frappe" zsh_theme_name="catppuccin_frappe" nvim_color_scheme="catppuccin-frappe" background_color="#303446" @@ -68,7 +70,7 @@ case $1 in ;; "gruvbox-dark") - alacritty_theme_name="gruvbox_dark" + terminal_theme_name="gruvbox_dark" zsh_theme_name="gruvbox_dark" nvim_color_scheme="gruvbox-material" background_color="#1d2021" @@ -86,11 +88,14 @@ case $1 in nvim --server /tmp/nvim.pipe --remote-send ':lua vim.opt.background = "dark"' || true echo "vim.opt.background = 'dark'" >> ~/.config/nvim/lua/core/theme.lua + #Change kitty theme + kitten themes --reload-in=all Gruvbox Dark + change_common ;; "gruvbox-light") - alacritty_theme_name="gruvbox_light" + terminal_theme_name="gruvbox_light" zsh_theme_name="gruvbox_light" nvim_color_scheme="gruvbox-material" background_color="#f2e5bc" @@ -108,6 +113,9 @@ case $1 in nvim --server /tmp/nvim.pipe --remote-send ':lua vim.opt.background = "light"' || true echo "vim.opt.background = 'light'" >> ~/.config/nvim/lua/core/theme.lua + #Change kitty theme + kitten themes --reload-in=all Gruvbox Light + change_common ;; From 8e64c3d0c9a32fb46266871852291f8ee58c5d31 Mon Sep 17 00:00:00 2001 From: afonso Date: Wed, 31 Jul 2024 14:25:30 +0100 Subject: [PATCH 7/7] [zsh] changed ZDOTDIR --- .zshenv | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/.zshenv b/.zshenv index bc14168..2f5e933 100644 --- a/.zshenv +++ b/.zshenv @@ -1,16 +1,2 @@ -#This is used to reload the instance -TRAPUSR1() { - if [[ -o INTERACTIVE ]]; then - exec "${SHELL}" - fi -} -if [[ $(uname) == "Darwin" ]]; then - export JAVA_HOME="/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home" -else - export LIBVA_DRIVER_NAME=nvidia -fi -export XDG_CONFIG_HOME="${HOME}/.config" -export XDG_CACHE_HOME="${HOME}/.cache" -export XDG_DATA_HOME="${HOME}/.local/share" -export XDG_STATE_HOME="${HOME}/.local/state" +export XDG_CONFIG_HOME="$HOME/.config" export ZDOTDIR="$XDG_CONFIG_HOME/zsh"