Grummfy
Jonathan Van Belle
@Grummfy
@Grummfy@mamot.fr
me@grummfy.be
github.com/grummfy
Contributeur open source : atoum, hoa, ...
[alias]
st = status
who = shortlog -sne
co = checkout
coma = commit -am
pu = push
undo = reset --soft HEAD^
oneline = log --pretty=oneline --abbrev-commit --graph --decorate
[alias]
oneline = log --pretty=oneline --abbrev-commit --graph --decorate
lc = !git oneline ORIG_HEAD.. --stat --no-merges # change since last pull
addm = !git-ls-files -m -z | xargs -0 git-add # add modified files
addu = !git-ls-files -o --exclude-standard -z | xargs -0 git-add # add unknown files
rem-extra = "!yolo() { git remote add $1 https://github.com/$2.git; }; yolo"
[alias]
author-pro = !exec git config --local user.name "jvb" && \
git config --local user.email "jvb@company.be"
author-perso = !exec git config --local user.name "Grummfy" && \
git config --local user.email "me@grummfy.be"
_MyAutocomplete ()
{
local cur prev words cword
_init_completion || return
case "$cur" in
-*)
COMPREPLY=( $( compgen -W '--help -h -v' -- $cur ) );;
esac
return 0
}
complete -F _MyAutocomplete supercommande
complete -C monScriptDautocomplete.php supercommande
# see /usr/share/bash-completion/completions/git
_git_author ()
{
case "$cur" in
*)
__gitcomp "perso pro"
return
;;
esac
}
peut casser avec l'évolution de git
# ~.bashrc
source /chemin/vers/fichier/de/completion
<?php
function animal($word) {
return ['elephant', 'elephpant'];
}
readline_completion_function('animal');
$reponse = readline('Quel est ton animal favoris? : ');
echo ((trim($reponse) == 'elephpant') ? 'Bravo' : 'bouuuuhhh') . PHP_EOL;
Question / Réponse
#!/usr/bin/php
<?php
function switchConfig(string $user, string $email, string $sign) {
passthru('git config --local user.name "' . $user . '"');
passthru('git config --local user.email "' . $email . '"');
passthru('git config --local user.signingkey "' . $sign . '"');
}
function help() { echo 'you ned help, too bad!', PHP_EOL; }
switch (@$argv[1]) {
case 'perso': switchConfig('Grummfy', 'me@grummfy.be', 'AAAEEEVV'); break;
case 'pro': switchConfig('jvb', 'jvb@company.tld', 'VVAAAEEE'); break;
default: help(); break;
}
⚠ git est un DCVS pas un task runner...
commentaires ⇒
les slides y seront aussi ;)