Skip to content

Instantly share code, notes, and snippets.

@hhc0null
Last active February 10, 2019 13:57
Show Gist options
  • Save hhc0null/fbd9ac6bb297e20a58b3af135b672b0a to your computer and use it in GitHub Desktop.
Save hhc0null/fbd9ac6bb297e20a58b3af135b672b0a to your computer and use it in GitHub Desktop.

Revisions

  1. hhc0null renamed this gist Feb 10, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. hhc0null created this gist Feb 10, 2019.
    42 changes: 42 additions & 0 deletions git-pull-each.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@

    function peco-history-selection() {
    BUFFER=$(history 1 | sort -k1,1nr | perl -ne 'BEGIN { my @lines = (); } s/^\s*\d+\*?\s*//; $in=$_; if (!(grep {$in eq $_} @lines)) { push(@lines, $in); print $in; }' | peco --query "$LBUFFER")
    CURSOR=${#BUFFER}
    zle reset-prompt
    }
    zle -N peco-history-selection
    bindkey -M vicmd "^R" peco-history-selection

    function select_pid() {
    initial_query=$( [[ -n "${1}" ]] && print "${1}" || print "")
    pid=$(ps aux | peco --query "${initial_query}" | awk '{print $2}' )
    print -n ${pid}
    }

    function att() {
    module_name=$( [[ -n "${1}" ]] && print "${1}" || print "")
    sudo gdb -q -x /usr/share/pwndbg/gdbinit.py -p $(select_pid "${module_name}")
    }

    function git-pull-each() {
    local -a pulling_failed_repos
    for repo in ${@}
    do
    builtin cd "${repo}"
    echo "Git-pull \"${repo}\" from \"$(git remote get-url origin)\""
    git pull
    if [ $? -eq 0 ]
    then
    pulling_failed_repos=(${pulling_failed_repos} ${repo})
    fi
    popd > /dev/null
    done

    if [ ${#pulling_failed_repos[@]} -eq 0 ]
    then
    for repo in ${pulling_failed_repos}
    do
    echo "Failed to pull => ${$repo}"
    done
    fi
    }