Skip to content

Instantly share code, notes, and snippets.

View davidmh's full-sized avatar
🐧

David Mejorado davidmh

🐧
View GitHub Profile
@davidmh
davidmh / gist:5689418
Last active December 17, 2015 23:29
Fast Next/Prev Post Links for large databases. http://wordpress.stackexchange.com/q/101435/
<?php # -*- coding: utf-8 -*-
namespace WPSE;
/* Plugin Name: Fast Next/Prev Post Links
* Plugin URI: http://wordpress.stackexchange.com/q/101435/
*/
add_action(
'fast_prev_post_link',
__NAMESPACE__ . '\fast_prev_post_link',
10,
@davidmh
davidmh / gist:6228319
Last active June 26, 2018 15:57
iTerm Tab & Window Titles with zsh and git. original: http://timbabwe.com/2012/05/iterm_tab_and_window_titles_with_zsh
function precmd() {
if command git rev-parse --git-dir > /dev/null 2>&1; then
window_label=$(git rev-parse --show-toplevel)
tab_label=$(echo $window_label | awk -F\/ '{print "[git] " $NF}')
else
window_label=${PWD/${HOME}/\~}
tab_label=$window_label
fi
echo -ne "\e]2;${window_label}\a"
echo -ne "\e]1;${tab_label: -24}\a"
@davidmh
davidmh / custom-post-type-archive-menu-links.php
Last active October 14, 2016 08:11 — forked from helgatheviking/custom-post-type-archive-menu-links.php
Adds Custom Post Type archives to the WordPress-powered menus. Compatible with WP 3.8
<?php
/*
Plugin Name: Custom Post Type Archive Menu Links
Plugin URI: http://codeseekah.com/2012/03/01/custom-post-type-archives-in-wordpress-menus-2/
Description: Easily Add Custom Post Type Archives to the Nav Menus
Version: 1.1
Author: soulseekah
Author URI: http://codeseekah.com
License: GPL2
@davidmh
davidmh / CtrlP_acceleration
Last active July 12, 2023 16:33 — forked from av-ast/CtrlP_acceleration
Accelerate CtrlP by ignoring certain files and paths. Including node modules and grunt's .tmp
" Ignore some folders and files for CtrlP indexing
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.yardoc\|node_modules\|log\|tmp$',
\ 'file': '\.so$\|\.dat$|\.DS_Store$'
\ }

Keybase proof

I hereby claim:

  • I am davidmh on github.
  • I am chaac (https://keybase.io/chaac) on keybase.
  • I have a public key whose fingerprint is 91DC 6839 9375 4082 600D 9318 9D55 8125 A705 A525

To claim this, I am signing this object:

@davidmh
davidmh / config.fish
Last active November 28, 2020 13:37
Showing git branch in fish shell prompt. Put following code at the end of ~/.config/fish/config.fish. It will also highlight in red if branch is dirty. Based on http://zogovic.com/post/37906589287/showing-git-branch-in-fish-shell-prompt
set fish_git_dirty_color red
set fish_git_not_dirty_color green
function parse_git_branch
set -l branch (git branch 2> /dev/null | grep -e '\* ' | sed 's/^..\(.*\)/\1/')
set -l git_status (git status -s)
if test -n "$git_status"
echo (set_color $fish_git_dirty_color)$branch(set_color normal)
else
@davidmh
davidmh / config.fish
Last active August 29, 2015 14:20
Fish prompt based on the minimal theme from oh-my-zsh. Put following code at the end of ~/.config/fish/config.fish. http://i.imgur.com/o7rOlRv.png
set fish_git_dirty_color red
set fish_git_not_dirty_color white
function parse_git_branch
set -l branch (git branch 2> /dev/null | grep -e '\* ' | sed 's/^..\(.*\)/\1/')
set -l git_status (git status -s)
if test -n "$git_status"
echo (set_color normal)$branch(set_color $fish_git_dirty_color)●(set_color normal)
else
let mapleader = "<Space>"
unmap b
map <Leader>b :buffer
map #n nextSearchResult
map n :execute #nzz<CR>
site '*://*.reddit.com/*' {
unmap j
unmap k
set numerichints
@davidmh
davidmh / fzf-reverse-i-search.vim
Created September 16, 2015 18:11
reverse-i-search for vim with fzf
" reverse-i-search
function! s:get_history()
redir => history
silent! history
redir END
return map(split(history, '\n'), "strpart(v:val, 9)")
endfunction
function! s:run_cmd(cmd)
execute a:cmd
endfunction
@davidmh
davidmh / fugitive-swoop.vim
Last active May 23, 2016 17:11
vim-fugitive + vim-swoop
function! Cmd2QuickFix(command, prompt, use_swoop)
" use the current word as the default value
let default = expand("<cword>")
call inputsave()
let pattern = input(a:prompt, default)
call inputrestore()
if empty(pattern)
echo a:command . ' needs a pattern, see :h ' . a:command
else
exe 'silent ' . a:command . ' ' . pattern . ' | redraw!'