Skip to content

Instantly share code, notes, and snippets.

@gidgid
gidgid / .vimrc
Created April 9, 2020 13:14
GFiles & Files with preview
command! -bang GFiles call fzf#vim#gitfiles('', fzf#vim#with_preview('right'))
command! -bang Files call fzf#vim#files('', fzf#vim#with_preview('right'))
@gidgid
gidgid / .vimrc
Created April 9, 2020 13:15
Ag with preview
command! -bang -nargs=* Ag call fzf#vim#ag(<q-args>, '--color-path "1;36"', fzf#vim#with_preview(), <bang>0)
@gidgid
gidgid / .gitconfig
Created April 9, 2020 13:17
Frequently used Git with FZF aliases
# Navigate to branches using FZF
cof = "!checkout_fzf() { git branch | fzf | xargs git checkout; }; checkout_fzf"
# Add files using FZF
af = "!add_fzf() { git status -s | awk '{print $2}' | fzf -m | xargs git add; }; add_fzf"
# Add files using FZF and immediately commit them
afmend = "!add_fzf_amend() { git status -s | awk '{print $2}' | fzf -m | xargs git add && git amend; }; add_fzf_amend"
# Restore files (like removing multiple files from the staging area)
ref = "!restore_fzf() { git status -s | awk '{print $2}' | fzf -m | xargs git restore; }; restore_fzf"
# Delete untracked files using FZF
rmf = "!delete_untracked() { git ls-files --exclude-standard --other | fzf -m | xargs rm; }; delete_untracked"
@gidgid
gidgid / .vimrc
Created April 9, 2020 13:24
Mapping :Snippets in vim insert mode
" <ESC> is required to get back to normal mode
inoremap <Leader>s <ESC>:Snippets<CR>i
@gidgid
gidgid / .zshrc (or .bashrc)
Last active June 26, 2023 19:32
Delete multiple files with FZF
# Delete multiple files with FZF
rmf() {
ls | fzf -m | xargs -I {} rm {}
}
@gidgid
gidgid / .zshrc (or .bashrc)
Created April 9, 2020 13:26
Kubectl helper function
kc() { kubectl -n ${NAMESPACE} --cluster ${CLUSTER_ID} $@ }
@gidgid
gidgid / env file example
Created April 9, 2020 13:27
An example file to source for Kubectl
export CLUSTER_NAME=<my-cluster-name>
export PROJECT_ID=<my-project-id>
export ENV=<env>
export NAMESPACE=<my-namespace>
export ZONE=<zone>
export CLUSTER_ID=gke_${PROJECT_ID}_${ZONE}_${CLUSTER_NAME}
@gidgid
gidgid / .zshrc (or .bashrc)
Last active April 9, 2020 13:29
Source different env files
# source relevant env files via fzf
# note that sf() can also be used without Kubectl
sf() {
find ~/.envs -type f | fzf | while read filename; do source $filename; done
}
@gidgid
gidgid / .zshrc (or .bashrc)
Created April 10, 2020 17:28
Activating virtual envs with FZF
vf() {
# note that you need to extract the absolute path in order to get this to work
ls -d ~/.virtualenv/*/ | fzf | while read file; do source $file/bin/activate; done
}
@gidgid
gidgid / inconsistant_naming.py
Last active October 2, 2020 11:36
Inconsistant Naming Conventions
from pydantic import BaseModel
class CamelCaseItem(BaseModel):
id: str
isAvailable: bool
def test_python_camel_case_names_are_weird_in_python():
item = CamelCaseItem(id='test-item-id', isAvailable=True)