From 03c7e76266bc829188d932457190999455a8fddc Mon Sep 17 00:00:00 2001 From: turtlebasket Date: Thu, 3 Mar 2022 23:39:50 -0800 Subject: [PATCH] update --- config/hammerspoon/init.lua | 60 +++++++++++++++++++++++------- config/vim/vimrc | 73 +++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 14 deletions(-) create mode 100644 config/vim/vimrc diff --git a/config/hammerspoon/init.lua b/config/hammerspoon/init.lua index b37d46b..b0eb570 100644 --- a/config/hammerspoon/init.lua +++ b/config/hammerspoon/init.lua @@ -1,16 +1,15 @@ - wf=hs.window.filter browser = "Brave Browser" -- Open new / focus existing terminal window in current desktop space hs.hotkey.bind({"cmd", "ctrl"}, "T", function() - wf_iterm2 = wf.new(false):setAppFilter("iTerm2", {currentSpace=true}) + wf_iterm2 = wf.new(false):setAppFilter("iTerm2", {currentSpace=true, visible=true}) local wins = wf_iterm2:getWindows() local count = 0 for _ in pairs(wins) do count = count + 1 end - + if (count > 0) then wf_iterm2:getWindows()[1]:focus() @@ -29,7 +28,7 @@ end) hs.hotkey.bind({"cmd", "ctrl"}, "W", function() - wf_browser = wf.new(false):setAppFilter(browser, {currentSpace=true}) + wf_browser = wf.new(false):setAppFilter(browser, {currentSpace=true, visible=true}) local wins = wf_browser:getWindows() local count = 0 @@ -49,13 +48,31 @@ hs.hotkey.bind({"cmd", "ctrl"}, "W", function() end) +-- CHROMIUM-BASED BROWSERS ONLY: Open new tab to right of current browser + +hs.hotkey.bind({"cmd", "option"}, "T", function() + + local focusedAppName = hs.window.focusedWindow():application():title() + + if focusedAppName == browser + then + hs.osascript.applescript(string.format([[ + tell application "System Events" to tell process "%s" + click menu item "New Tab to the Right" of menu "Tab" of menu bar 1 + end tell + ]], focusedAppName)) + else + hs.notify.new({title=string.format("%s not focused.", browser)}):send() + end + +end) -- Open new / focus existing vscode window in current desktop space -hs.hotkey.bind({"cmd", "ctrl"}, "C", function() +hs.hotkey.bind({"cmd", "ctrl"}, "V", function() local app = "Code" - wf_app = wf.new(false):setAppFilter(app, {currentSpace=true}) + wf_app = wf.new(false):setAppFilter(app, {currentSpace=true, visible=true}) local wins = wf_app:getWindows() local count = 0 @@ -77,12 +94,12 @@ hs.hotkey.bind({"cmd", "ctrl"}, "C", function() end) --- Open new / focus existing VimR window in current desktop space +-- Open new / focus existing g/n/mac/vim(r) window in current desktop space -hs.hotkey.bind({"cmd", "ctrl"}, "V", function() - local app = "VimR" +hs.hotkey.bind({"cmd", "ctrl"}, "E", function() + local app = "MacVim" - wf_app = wf.new(false):setAppFilter(app, {currentSpace=true}) + wf_app = wf.new(false):setAppFilter(app, {currentSpace=true, visible=true}) local wins = wf_app:getWindows() local count = 0 @@ -92,10 +109,9 @@ hs.hotkey.bind({"cmd", "ctrl"}, "V", function() then wf_app:getWindows()[1]:focus() else - hs.osascript.applescript(string.format([[ tell application "System Events" to tell process "%s" - click menu item "New" of menu "File" of menu bar 1 + click menu item "New Window" of menu "File" of menu bar 1 set frontmost to true end tell ]], app)) @@ -105,6 +121,23 @@ hs.hotkey.bind({"cmd", "ctrl"}, "V", function() end) +-- Show Desktop (like windows or KDE) + +hs.hotkey.bind({"alt"}, "d", function() + hs.eventtap.keyStroke({"fn"}, "f11") +end) + +-- Switch Desktops (like windows or KDE) + +hs.hotkey.bind({"ctrl", "alt"}, "left", function() + hs.eventtap.keyStroke({"ctrl"}, "left") +end) + +hs.hotkey.bind({"ctrl", "alt"}, "right", function() + hs.eventtap.keyStroke({"ctrl"}, "right") +end) + + -- Expose Windows (Mission Control) hs.hotkey.bind({"alt"}, "tab", function() @@ -115,7 +148,7 @@ end) hs.hotkey.bind({"cmd", "shift", "ctrl"}, "C", function() hs.pasteboard.setContents("") - hs.notify.new({title="Bazinga", informativeText="System clipboard has been cleared."}):send() + hs.notify.new({title="Cleared clipboard."}):send() end) -- The ShiftIt Alternative @@ -144,4 +177,3 @@ hs.hotkey.bind(mash, '[', function() hs.window.focusedWindow():move(units.upleft hs.hotkey.bind(mash, ';', function() hs.window.focusedWindow():move(units.botleft50, nil, true) end) hs.hotkey.bind(mash, "'", function() hs.window.focusedWindow():move(units.botright50, nil, true) end) hs.hotkey.bind(mash, 'm', function() hs.window.focusedWindow():move(units.maximum, nil, true) end) - diff --git a/config/vim/vimrc b/config/vim/vimrc new file mode 100644 index 0000000..8eb3bb4 --- /dev/null +++ b/config/vim/vimrc @@ -0,0 +1,73 @@ +" Win behavior +" source $VIMRUNTIME/mswin.vim +" behave mswin + +" Window height +" set lines=32 columns=110 + +" Preferences +set encoding=utf-8 +set autochdir +set shiftwidth=4 +set tabstop=4 +set linebreak +set breakindent +set autoindent +set wrap +set nobinary +set relativenumber +syntax on +set belloff=all + +set guifont=CaskaydiaCove\ Nerd\ Font:h12 + +" Aliases +cnoreabbrev ge browse confirm e +cnoreabbrev ! aliasrun + +" Plugins +call plug#begin() +Plug 'vim-airline/vim-airline' +Plug 'vim-airline/vim-airline-themes' +Plug 'airblade/vim-gitgutter' +Plug 'flazz/vim-colorschemes' +Plug 'tomlion/vim-solidity' +Plug 'zah/nim.vim' +Plug 'NLKNguyen/papercolortheme' +Plug 'ackyshake/VimCompletesMe' +Plug 'preservim/nerdtree' +call plug#end() + +" Theming +set t_Co=256 +set background=dark +colorscheme PaperColor +let g:airline_powerline_fonts = 1 +let g:airline_theme = 'powerlineish' +let g:airline#extensions#tabline#enabled = 1 +let g:airline#extensions#tabline#fnamemod = ':t' + + +" Navigation & Shortcuts + +" NERDTree Stuff +nnoremap n :NERDTreeFocus +nnoremap :NERDTree +nnoremap :NERDTreeToggle +nnoremap :NERDTreeFind + +" Copy/paste stuff +" inoremap "+y +" inoremap :"+p + +" Tab stuff +nnoremap 1gt +nnoremap 2gt +nnoremap 3gt +nnoremap 4gt +nnoremap 5gt +nnoremap 6gt +nnoremap 7gt +nnoremap 8gt +nnoremap 9gt +nnoremap 10gt-