Skip to content

Instantly share code, notes, and snippets.

@adithyasource
Last active July 1, 2024 20:48
Show Gist options
  • Save adithyasource/60212c77c98e253937ad010a94430c6c to your computer and use it in GitHub Desktop.
Save adithyasource/60212c77c98e253937ad010a94430c6c to your computer and use it in GitHub Desktop.
random config files and notes that i use and update regularly
-- to mount iSH to iOS folder
mount -t ios . dawn
apk add git openssh-keygen openssh bash vim
-- after cloning the git repository
chmod +x sync.sh
vim /etc/profile
alias s="/bin/sh sync.sh"
<sync.sh>
#!/bin/bash
cd dawn
git pull origin
# decided that i want the vault to be written to exclusively from my pc
#
# if [ -n "$(git status --porcelain)" ]; then
# git add .
# git commit -m "auto commited from iphone"
# git push origin
# fi
#
# ~/.bashrc
#
alias t="tmux"
alias ts="tmux ls"
alias tk='tmux kill-session -t'
alias ta='tmux a -t'
alias tc='tmux new -s'
alias c="clear"
alias ls="ls -a --color=auto"
alias g="lazygit"
<input.conf>
MBTN_MID quit
<mpv.conf>
loop-file=inf
--no-border
script-opts=osc-visibility=never
geometry=40%
autofit=100%
---- notes
--- requirements
-- neovim (tested to work on v0.10.0)
-- git [paq, mason, gitsigns]
-- file archiver (ex: winrar, 7zip) [mason]
-- nodejs [some of the tooling installed by mason use nodejs]
-- ripgrep [spectre]
-- sed (download github.com/mbuilov/sed-windows if on windows) [spectre]
--- install instructions
-- open nvim's config file (init.lua)
-- paste in this config
-- reopen nvim
-- ignore all errors from nvim
-- run :PaqInstall and wait for all plugins to install
-- reopen nvim
-- wait for mason to install lsps and formatters (check progress using :Mason)
-- reopen nvim and everything should initialize properly now
---- vim behaviour
vim.g.mapleader = " " -- space as leader
vim.g.netrw_liststyle = 3 -- netrw file explorer tree view mode
vim.opt.guicursor = "n-v-i-c:block-Cursor" -- block cursor style in all modes
vim.opt.nu = true -- absolute line numbers
vim.opt.relativenumber = true -- relative line numbers
vim.opt.expandtab = true -- converts tabs to spaces
vim.opt.shiftwidth = 2 -- 2 spaces inserted during indentation
vim.opt.wrap = false -- no line wrapping
vim.opt.swapfile = false -- no swap files
vim.opt.backup = false -- no backup files
vim.opt.undofile = true -- persistent undo
vim.opt.hlsearch = false -- no highlighting of search matches
vim.opt.incsearch = true -- incremental search, shows matches as you type
vim.opt.scrolloff = 8 -- keeps 8 lines visible above and below the cursor while scrolling
vim.opt.signcolumn = "yes" -- always shows the sign column on the left for gitsigns or error icons
vim.opt.colorcolumn = "80" -- highlights the 80th column
vim.opt.cursorline = true -- highlights the row where the cursor is located
vim.opt.list = true -- allows for visualization of invisible characters
vim.opt.listchars = { tab = ">~" } -- shows >~ in place of tab
vim.opt.ignorecase = true -- ignores case in search
vim.opt.smartcase = true -- cares about case if there are capital cases in search query
vim.loader.enable() -- improves startup time by a bit
-- auto excludes all .gitignore files and dirs in ctrlp
vim.g.ctrlp_user_command = { ".git/", "git --git-dir=%s/.git ls-files -oc --exclude-standard" }
-- run formatter on save
vim.api.nvim_create_autocmd("BufWritePost", {
callback = function()
if vim.fn.exists(":FormatWrite") > 0 then
vim.cmd("FormatWrite")
end
end,
})
---- keybinds
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv") -- move line(s) down
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv") -- move line(s) up
vim.keymap.set("x", "p", [["_dP]]) -- on paste over, the copied text stays in clipboard
vim.keymap.set({ "n", "v" }, "d", [["_d]]) -- on delete, deleted text doesnt go to clipboard
vim.keymap.set("n", "<C-s>", "<cmd>write<CR>") -- format and save
vim.keymap.set("n", "<leader>e", "<cmd>edit .<CR>", {}) -- open netrw
-- for lsp
vim.keymap.set("n", "K", vim.lsp.buf.hover)
vim.keymap.set("n", "H", vim.lsp.buf.definition)
-- find and replace
vim.keymap.set("n", "<leader>S", '<cmd>lua require("spectre").toggle(); vim.cmd("wincmd L")<CR>', {})
vim.keymap.set("n", "<leader>sf", '<cmd>lua require("spectre").open_file_search(); vim.cmd("wincmd L")<CR>', {})
-- harpoon
vim.keymap.set("n", "<leader>ha", "<cmd>lua require('harpoon.mark').add_file()<CR>", {})
vim.keymap.set("n", "<leader>hs", "<cmd>lua require('harpoon.ui').toggle_quick_menu()<CR>", {})
vim.keymap.set("n", "<M-1>", "<cmd>lua require('harpoon.ui').nav_file(1)<CR>", {})
vim.keymap.set("n", "<M-2>", "<cmd>lua require('harpoon.ui').nav_file(2)<CR>", {})
vim.keymap.set("n", "<M-3>", "<cmd>lua require('harpoon.ui').nav_file(3)<CR>", {})
vim.keymap.set("n", "<M-4>", "<cmd>lua require('harpoon.ui').nav_file(4)<CR>", {})
vim.keymap.set("n", "<M-q>", "<cmd>lua require('harpoon.term').gotoTerminal(1)<CR>", {})
vim.keymap.set("n", "<M-w>", "<cmd>lua require('harpoon.term').gotoTerminal(2)<CR>", {})
vim.keymap.set("n", "<M-e>", "<cmd>lua require('harpoon.term').gotoTerminal(3)<CR>", {})
vim.keymap.set("n", "<M-r>", "<cmd>lua require('harpoon.term').gotoTerminal(4)<CR>", {})
-- git
vim.keymap.set("n", "<leader>gg", "<cmd>lua require('gitsigns').preview_hunk_inline()<CR>", {})
vim.keymap.set("n", "<leader>gn", "<cmd>lua require('gitsigns').next_hunk()<CR>", {})
vim.keymap.set("n", "<leader>gp", "<cmd>lua require('gitsigns').prev_hunk()<CR>", {})
-- hop
vim.keymap.set(
"",
"f",
'<cmd>lua require("hop").hint_char1({ direction = require("hop.hint").HintDirection.AFTER_CURSOR, current_line_only = true })<CR>'
)
vim.keymap.set(
"",
"F",
'<cmd>lua require("hop").hint_char1({ direction = require("hop.hint").HintDirection.BEFORE_CURSOR, current_line_only = true })<CR>'
)
vim.keymap.set(
"",
"<leader>f",
'<cmd>lua require("hop").hint_char1({ direction = require("hop.hint").HintDirection.AFTER_CURSOR, current_line_only = false })<CR>'
)
vim.keymap.set(
"",
"<leader>F",
'<cmd>lua require("hop").hint_char1({ direction = require("hop.hint").HintDirection.BEFORE_CURSOR, current_line_only = false })<CR>'
)
---- installing plugins
--- bootstrapping paq
local paq_path = vim.fn.stdpath("data") .. "/site/pack/paqs/start/paq-nvim"
if not vim.loop.fs_stat(paq_path) then
vim.fn.system({
"git",
"clone",
"https://github.com/savq/paq-nvim.git",
paq_path,
})
end
vim.cmd([[packadd paq-nvim]])
--- defining plugins to install
require("paq")({
-- paq will manage paq itself
"savq/paq-nvim",
-- lsp and formatter installer
"williamboman/mason.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
-- setting up lsps
"neovim/nvim-lspconfig",
-- setting up formatters
"mhartington/formatter.nvim",
-- better autocomplete
"hrsh7th/nvim-cmp",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
-- color scheme
"ribru17/bamboo.nvim",
-- git signs
"lewis6991/gitsigns.nvim",
-- indentation guidelines
"lukas-reineke/indent-blankline.nvim",
-- autoclose brackets and that
"m4xshen/autoclose.nvim",
-- better cursor hopping
"smoka7/hop.nvim",
-- dont need the scrollbar
-- just want it for the git and lsp indicators
"dstein64/nvim-scrollview",
-- find and replace [no setup]
"nvim-pack/nvim-spectre",
-- multi cursor [no setup]
"mg979/vim-visual-multi",
-- ctrl + p file finder [no setup]
"ctrlpvim/ctrlp.vim",
-- jump around files [no setup]
"ThePrimeagen/harpoon",
--- dependency required by { spectre, harpoon } [no setup]
"nvim-lua/plenary.nvim",
})
---- setting up plugins
require("mason").setup()
require("mason-tool-installer").setup({
ensure_installed = {
-- language servers
"tailwindcss-language-server",
"eslint-lsp",
"typescript-language-server",
"biome",
"lua-language-server",
"pyright",
"rust-analyzer",
-- formatters
"prettierd",
"stylua",
"black",
"rustfmt",
},
})
local lsp_config = require("lspconfig")
lsp_config.tailwindcss.setup({})
lsp_config.eslint.setup({})
lsp_config.tsserver.setup({})
lsp_config.biome.setup({})
lsp_config.lua_ls.setup({
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
},
},
})
lsp_config.pyright.setup({})
lsp_config.rust_analyzer.setup({
settings = {
["rust-analyzer"] = {
check = {
command = "clippy",
},
diagnostics = {
enable = true,
},
},
},
})
require("formatter").setup({
filetype = {
lua = {
require("formatter.filetypes.lua").stylua,
},
javascript = {
require("formatter.filetypes.javascript").prettierd,
},
javascriptreact = {
require("formatter.filetypes.javascriptreact").prettierd,
},
css = {
require("formatter.filetypes.css").prettierd,
},
json = {
require("formatter.filetypes.json").prettierd,
},
python = {
require("formatter.filetypes.python").black,
},
rust = {
require("formatter.filetypes.rust").rustfmt,
},
},
})
local cmp = require("cmp")
cmp.setup({
sources = {
{ name = "nvim_lsp" },
{ name = "buffer" },
{ name = "path" },
},
mapping = cmp.mapping.preset.insert({
["<CR>"] = cmp.mapping.confirm({ select = true }),
}),
})
require("bamboo").load()
require("gitsigns").setup()
require("ibl").setup({ indent = { char = "|" } })
require("autoclose").setup()
require("hop").setup({ keys = "etovxqpdygfblzhckisuran" })
require("scrollview").setup({
base = "buffer",
column = 82,
signs_on_startup = { "all" },
})
require("scrollview.contrib.gitsigns").setup({})
; Switch / Create / Delete Desktops
; [stolen from https://www.autohotkey.com/boards/viewtopic.php?p=491217#p491217]
DesktopCount = 9
CurrentDesktop = 1
mapDesktopsFromRegistry()
OutputDebug, [loading] desktops: %DesktopCount% current: %CurrentDesktop%
^!1::switchDesktopByNumber(1)
^!2::switchDesktopByNumber(2)
^!3::switchDesktopByNumber(3)
^!4::switchDesktopByNumber(4)
^!5::switchDesktopByNumber(5)
^!6::switchDesktopByNumber(6)
^!7::switchDesktopByNumber(7)
^!8::switchDesktopByNumber(8)
^!9::switchDesktopByNumber(9)
^!Enter::
Send, ^{LWin down}{LCtrl down}d{LCtrl up}{LWin up}
Return
^!Backspace::
Send, ^{LWin down}{LCtrl down}{F4}{LCtrl up}{LWin up}
Return
mapDesktopsFromRegistry() {
global CurrentDesktop, DesktopCount
IdLength := 32
SessionId := getSessionId()
if (SessionId) {
RegRead, CurrentDesktopId, HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SessionInfo\%SessionId%\VirtualDesktops, CurrentVirtualDesktop
if (CurrentDesktopId) {
IdLength := StrLen(CurrentDesktopId)
}
}
RegRead, DesktopList, HKEY_CURRENT_USER, SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VirtualDesktops, VirtualDesktopIDs
if (DesktopList) {
DesktopListLength := StrLen(DesktopList)
DesktopCount := DesktopListLength / IdLength
}
else {
DesktopCount := 1
}
i := 0
while (CurrentDesktopId and i < DesktopCount) {
StartPos := (i * IdLength) + 1
DesktopIter := SubStr(DesktopList, StartPos, IdLength)
OutputDebug, The iterator is pointing at %DesktopIter% and count is %i%.
if (DesktopIter = CurrentDesktopId) {
CurrentDesktop := i + 1
OutputDebug, Current desktop number is %CurrentDesktop% with an ID of %DesktopIter%.
break
}
i++
}
}
getSessionId()
{
ProcessId := DllCall("GetCurrentProcessId", "UInt")
if ErrorLevel {
OutputDebug, Error getting current process id: %ErrorLevel%
return
}
OutputDebug, Current Process Id: %ProcessId%
DllCall("ProcessIdToSessionId", "UInt", ProcessId, "UInt*", SessionId)
if ErrorLevel {
OutputDebug, Error getting session id: %ErrorLevel%
return
}
OutputDebug, Current Session Id: %SessionId%
return SessionId
}
switchDesktopByNumber(targetDesktop)
{
global CurrentDesktop, DesktopCount
mapDesktopsFromRegistry()
if (targetDesktop > DesktopCount || targetDesktop < 1) {
OutputDebug, [invalid] target: %targetDesktop% current: %CurrentDesktop%
return
}
while(CurrentDesktop < targetDesktop) {
Send ^#{Right}
CurrentDesktop++
OutputDebug, [right] target: %targetDesktop% current: %CurrentDesktop%
}
while(CurrentDesktop > targetDesktop) {
Send ^#{Left}
CurrentDesktop--
OutputDebug, [left] target: %targetDesktop% current: %CurrentDesktop%
}
}
; Always on Top
^+SPACE::{
WinSetAlwaysOnTop -1, "A"
}
; Media Keys
RAlt & Space::Send "{Media_Play_Pause}"
^!Left::Send "{Media_Prev}"
^!Right::Send "{Media_Next}"
^!M::Send "{Volume_Mute}"
RShift::Send "{Volume_Up}"
RCtrl::Send "{Volume_Down}"
; Audio Source
; [stolen from https://www.reddit.com/r/AutoHotkey/comments/156pt7i/comment/jt11b8k/]
SoundOutput(DeviceName?) {
list := _DeviceList()
deviceId := _GetDeviceID()
if (!IsSet(DeviceName)) {
return LTrim(list, "`n")
}
if (deviceId = "") {
MsgBox('Device "' DeviceName '" not found.`n`nCurrent devices:`n' list, "Error", 0x40010)
return
}
try {
IPolicyConfig := ComObject("{870AF99C-171D-4F9E-AF0D-E63DF40C2BC9}", "{F8679F50-850A-41CF-9C72-430F290290C8}")
ComCall(13, IPolicyConfig, "Str", deviceId, "UInt", 0)
} catch {
MsgBox("SoundOutput() failed for device " DeviceName, "Error", 0x40010)
}
_DeviceList() {
static eRender := 0, STGM_READ := 0, DEVICE_STATE_ACTIVE := 1
devices := Map()
IMMDeviceCollection := count := IMMDevice := IPropertyStore := 0
IMMDeviceEnumerator := ComObject("{BCDE0395-E52F-467C-8E3D-C4579291692E}", "{A95664D2-9614-4F35-A746-DE8DB63617E6}")
ComCall(3, IMMDeviceEnumerator, "UInt", eRender, "UInt", DEVICE_STATE_ACTIVE, "Ptr*", &IMMDeviceCollection)
ComCall(3, IMMDeviceCollection, "UInt*", &count)
pk := Buffer(20, 0)
pv := Buffer(A_PtrSize = 8 ? 24 : 16, 0)
loop count {
ComCall(4, IMMDeviceCollection, "UInt", A_Index - 1, "Ptr*", &IMMDevice)
ComCall(5, IMMDevice, "Str*", &devId)
ComCall(4, IMMDevice, "UInt", STGM_READ, "Ptr*", &IPropertyStore)
ObjRelease(IMMDevice)
DllCall("ole32\CLSIDFromString", "Str", "{A45C254E-DF1C-4EFD-8020-67D146A850E0}", "Ptr", pk.Ptr)
NumPut("UInt", 14, pk.Ptr, 16)
ComCall(5, IPropertyStore, "Ptr", pk.Ptr, "Ptr", pv.Ptr)
ObjRelease(IPropertyStore)
pwszVal := NumGet(pv.Ptr, 8, "Ptr")
devName := StrGet(pwszVal)
devices[devName] := devId
}
ObjRelease(IMMDeviceCollection)
return devices
}
_GetDeviceID() {
clone := list.Clone()
list := found := ""
for name, id in clone {
if (IsSet(DeviceName) && InStr(name, DeviceName)) {
found := id
}
list .= "`n- " name
}
return found
}
}
^!F1::SoundOutput("Headphones (High Definition Audio Device)")
^!F2::SoundOutput("Speakers (High Definition Audio Device)")
^!F3::SoundOutput("Headphones (Nothing ear (1))")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment