https://github.com/kislyuk/argcomplete
argcomplete - Bash tab completion for argparse Tab complete all the things!
Argcomplete provides easy, extensible command line tab completion of arguments for your Python script.
It makes two assumptions:
# Required: boltons, nested_dict | |
from boltons.iterutils import remap | |
from nested_dict import nested_dict | |
def ndict(data): | |
""" | |
Create a defaultdict-like dictionary that allows accessing nested keys without getting | |
KeyErrors or TypeErrors. | |
Regular dict: |
#!/usr/bin/env python | |
# | |
# Show URL of file in git, optionally open URL in browser. | |
# In contrast to 'hub' this works to Github *and* Gitlab. | |
# | |
# Requirements: GitPython, click | |
import logging | |
import os | |
import sys | |
import webbrowser |
import subprocess | |
logger = logging.getLogger(__name__) | |
def ssh_tunnel(jumphost, remote_server, local_port, remote_port, | |
control_socket='/tmp/ssh_socket'): | |
""" | |
Establish SSH tunnel | |
:param jumphost: jump host |
#!/usr/bin/env python | |
# Parse Icinga object cache file into proper data structure | |
import re | |
import logging | |
logger = logging.getLogger(__name__) | |
def parse_config(cache_file): | |
""" |
https://github.com/kislyuk/argcomplete
argcomplete - Bash tab completion for argparse Tab complete all the things!
Argcomplete provides easy, extensible command line tab completion of arguments for your Python script.
It makes two assumptions:
#!/usr/bin/env bash | |
# Saves todays ipython history to textfile. | |
# Needs inotify-tools, sqlite3 | |
HISTORY_SQLITE="${HOME}/.config/ipython/profile_default/history.sqlite" | |
HISTORY_FILE="${HOME}/.config/ipython/profile_default/history.py" | |
if [ ! -f "${HISTORY_FILE}" ]; then | |
touch "${HISTORY_FILE}" | |
fi |
#!/usr/bin/env python | |
"""Extract a session from the IPython input history. | |
""" | |
import sys | |
import codecs | |
from IPython.core.history import HistoryAccessor | |
class MyHistoryAccessor(HistoryAccessor): | |
""" Modified HistoryAccessor to fetch the whole ipython history across all sessions """ |