Created
June 9, 2015 13:13
-
-
Save takac/bb1bc81129fecc672c02 to your computer and use it in GitHub Desktop.
Useful shell functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function agv() | |
{ | |
command ag $@ | vim -c "setlocal buftype=nofile bufhidden=hide noswapfile" -c "let @/="'"'$@'"'" | set hls" - | |
} | |
# List files in git status using relative paths | |
function gip() | |
{ | |
# Can provide a matcher against the porcelain tags, i.e. "M ", "UU", etc | |
# If not provided return all files listed in git status | |
if [[ "$1" == "" ]]; then | |
local TYPE=".." | |
else | |
local TYPE="$1" | |
fi | |
local TOP_DIR=$(git rev-parse --show-toplevel) | |
# resolve the current relativity to the git dir | |
local REL="$(python -c 'import os.path; print os.path.relpath("'"$TOP_DIR"'", os.path.abspath("."))')" | |
git status --porcelain | sed -ne "/^$TYPE/s/^$TYPE \+/$REL\//p" -e 's/\n/ /' | |
} | |
function gim() | |
{ | |
vim $(gip) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment