Skip to content

Instantly share code, notes, and snippets.

@webknjaz
Created September 5, 2016 17:14
Show Gist options
  • Save webknjaz/7884eac589cc7738ace76487946ea8dc to your computer and use it in GitHub Desktop.
Save webknjaz/7884eac589cc7738ace76487946ea8dc to your computer and use it in GitHub Desktop.
by @ahlinc
pydbg ()
{
local PYCHARM_HOST=${PYCHARM_HOST:-127.0.0.1};
local PYCHARM_PORT=${PYCHARM_PORT:-6000};
local extra;
[ "$1" == "--module" ] && {
shift;
extra="$extra --module"
};
[ "$1" == "--suspend" ] && {
shift;
extra="$extra --suspend"
};
local cmd=$1;
shift;
local file;
if file=`pyenv which "$cmd"`; then
local pydev="$(realpath $(dirname $(cat /proc/`pgrep pycharm`/cmdline | tr \\0 \\n | sed -n '2p'))/..)/helpers/pydev/pydevd.py";
pydev="$pydev --client $PYCHARM_HOST --port $PYCHARM_PORT";
python $pydev $extra --file "$file" "$@";
else
echo "Can't find python file for: $cmd" 1>&2;
return 1;
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment