Last active
February 10, 2019 13:57
-
-
Save hhc0null/fbd9ac6bb297e20a58b3af135b672b0a to your computer and use it in GitHub Desktop.
memo
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 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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment