From 5c47dce0a8e85ab76a61bbdaedad81120725f6da Mon Sep 17 00:00:00 2001 From: Jannik ZANDER Date: Sat, 14 May 2016 23:26:42 +0200 Subject: [PATCH] Add cscope git hook --- .bash/aliases | 12 +----------- .git_template/hooks/cscope | 10 ++++++++++ .git_template/hooks/gtags | 9 +++++++++ .gitconfig | 2 ++ 4 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 .git_template/hooks/cscope create mode 100644 .git_template/hooks/gtags diff --git a/.bash/aliases b/.bash/aliases index a9a96f0..2eff3b2 100644 --- a/.bash/aliases +++ b/.bash/aliases @@ -17,8 +17,6 @@ alias -- -6="cd -6" alias -- -7="cd -7" alias -- -8="cd -8" alias -- -9="cd -9" -# alias ++ pushd -# alias -- popd # Secure settings alias rm='rm -i' @@ -34,13 +32,9 @@ alias egrep='egrep --color=auto' # show differences in color alias fgrep='fgrep --color=auto' # show differences in color # Shortcuts -alias d="cd ~/Documents" -alias dl="cd ~/Downloads" -alias dt="cd ~/Desktop" -alias w="cd ~/work" -alias g="git" alias h="history" alias j="jobs" +alias gg="global -grx" LS_COMMON="-hF" @@ -96,10 +90,6 @@ done # Reload the shell (i.e. invoke as a login shell) alias reload="exec $SHELL -l" -# Update dotfiles -alias pull.='pushd ~/.dotfiles && git pull && stow -vR * && popd' -alias push.='pushd ~/.dotfiles && git commit -a && git push && popd' - # alias bashhere='chere -il -t mintty -s bash' alias newterm='mintty /bin/env CHERE_INVOKING=1 /bin/bash -l &' alias gtypist='gtypist -wi' diff --git a/.git_template/hooks/cscope b/.git_template/hooks/cscope new file mode 100644 index 0000000..494e20c --- /dev/null +++ b/.git_template/hooks/cscope @@ -0,0 +1,10 @@ +#!/bin/sh +set -e +PATH="/usr/local/bin:$PATH" +dir="`git rev-parse --git-dir`" +trap 'rm -f "$dir/$$.cscope.out"' EXIT INT TERM +git ls-files |\ + grep -E '\.(c(pp)?|h)$' |\ + awk '{print "\""$0"\""}' |\ + cscope -R -b -i - -f "$dir/$$.cscope.out" +mv "$dir/$$.cscope.out" "$dir/../cscope.out" diff --git a/.git_template/hooks/gtags b/.git_template/hooks/gtags new file mode 100644 index 0000000..9ceba97 --- /dev/null +++ b/.git_template/hooks/gtags @@ -0,0 +1,9 @@ +#! /bin/sh +set -e +PATH="/usr/local/bin:$PATH" +dir="`git rev-parse --git-dir`" +trap 'rm -rf "$dir/$$.gtags" EXIT INT TERM +mkdir "$dir/$$.gtags" +git ls-files | \ + gtags --file=- --skip-unreadable "$dir/$$.gtags" +mv "$dir/$$.gtags/*" "$dir/.." diff --git a/.gitconfig b/.gitconfig index 71d9aa6..6c33c11 100644 --- a/.gitconfig +++ b/.gitconfig @@ -112,6 +112,8 @@ root = rev-parse --show-toplevel ctags = "!sh -c '[ -f .git/hooks/ctags ] || git init; .git/hooks/ctags' git-ctags" gtags = "!sh -c '[ -f .git/hooks/gtags ] || git init; .git/hooks/gtags' git-gtags" + cscope = "!sh -c '[ -f .git/hooks/cscope ] || git init; .git/hooks/cscope' git-cscope" + [include] # Local/private config goes in the include path = ~/.gitconfig_local -- 2.43.0