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PHRYDSWIQM7KXHGTWS3GOQC 2P4N7P2I5G7VI6MLRW3LBTOTQJUPGGTR35X7XZSRWLPIJSGTKZIQC MTWL5VOWRJZVR262KDQLY6WXTH2OY7YANNXZ7BKLN2R7G7JKNSHQC RQAM2DALWSFFSYJUHCENWU2MVW6YQS5ZB3ZX7NJKQ3NIF2IBXKNAC IIDU4QUMJGBATIMHZ6BQEXUUZ5PTSNEG5N2DVGJEOEJINYMNQ3XAC IGM75BIHVB7ITQCKH27R7ND5FFFBUTRE76ZWYGYMSWOSLDH7JCGAC JTUFSX4JQXMWPJ7I434LH7UYDRG6CJCADVKFROZCUW2IPX6AJ4ZQC PNRVNQAR5O3OUU7QLQFUHE3RRDPHTN55MTMXQZ27TKYHNFGNXB2AC 7XDSK4NCXZTGTYEKI4ZPL763GDQQYMYP6OJZW2JGSQ7B5JVV7BKAC XC5KCVUWLPJA4Q5IVLLQ25YWTE3DRUCJ3F3X4PW2VFCH4FQW7CAQC IMOTK232APTO5HACVM2LWJXLF77PYVDGWPCMFBX3NMQUWRAFCUOAC K6HI6ALCDQQONHZAJ7HUTDNRWECT6A5WM5EW6KNXFOPJZJVOLYIQC GI4RONJBJVXXCLIUUZ4IEGH3FS3TCZZXLNJ3WQQJ4CPTJENKFKCAC HKFGC6XAMYU7UYXEMYAA3D6W6BE6CQYTLIWOAJHJ3T7NMKCQPLEAC ONMM7DGS45XMAQXFZBYP4BBCTZJWCECNGCNOI6UFGYZGJ5TYXPAAC from collections import (defaultdict,Sequence,)import reimport subprocessimport sixdef find_credentials(search_term):lastpass_accounts = subprocess.Popen('lpass ls',shell=True,stdout=subprocess.PIPE,matching_accounts = map(lambda account: tuple(# produces: (account_name, account_id)re.sub('[\[\]]', '', account).strip().split(' id:')),(if re.match('.*{}.*'.format(search_term),account,re.IGNORECASE)))# TODO: allow user to fuzzy find when multiple matches# fzf won't work in a jupyter console :(account_name, account_id = list(matching_accounts)[0]password = subprocess.Popen('lpass show -p {}'.format(account_id),shell=True,stdout=subprocess.PIPE,return account_name, passwordclass EventbriteAPI(object):_BASE_EVENTBRITE_API_URL = 'https://www.{domain}.com/v3/'BASE_EVENTBRITE_API_URL_PROD = _BASE_EVENTBRITE_API_URL.format(domain='eventbriteapi')BASE_EVENTBRITE_API_URL_QA = _BASE_EVENTBRITE_API_URL.format(domain='evbqaapi')BASE_EVENTBRITE_API_URL_DEV = _BASE_EVENTBRITE_API_URL.format(domain='evbdevapi')EVENTBRITE_API_URL_MAP = {'prod': BASE_EVENTBRITE_API_URL_PROD,'qa': BASE_EVENTBRITE_API_URL_QA,'dev': BASE_EVENTBRITE_API_URL_DEV}self.base_url = self.EVENTBRITE_API_URL_MAP.get(self.environment, self.BASE_EVENTBRITE_API_URL_QA)def reset_token(self, credentials=None):self.token = credentials or find_credentials('{} token'.format(self.environment))[1]def retrieve_n_pages(self, path, pages=None, **kwargs):headers.update(kwargs.pop('headers', {}))results = defaultdict(list)continuation_token = Nonenext_page = 1parameters.update(kwargs.pop('params', {}))api_response = get(headers=headers,params=parameters,**kwargs)if not api_response.ok:results['errors'].append({'request': api_response.request,'error': api_response.text})breakresponse_json = api_response.json()for key, val in six.iteritems(response_json):if isinstance(val, Sequence):results[key].extend(val)else:results[key].append(val)return resultsdef get_events(self, pages=None, **kwargs):return self.retrieve_n_pages('/users/me/events/',pages=pages,**kwargs)['events']def verify_response_properties(self, response, props):'''pass in a dictionary of properties to an optional validaion function tocheck that a response has that property and is truthy or the validation function returns something truthy '''def verify_properties(dictionary, props):errors = []for prop, validation_func in six.iteritems(props):try:response_property_value = dictionary[prop]except KeyError:errors.append({'type': 'PROP_NOT_IN_RESPONSE','message': 'prop {} is not included in response'.format(prop),'property_value': dictionary})continuetry:is_valid = validation_func(response_property_value)except TypeError:# type error is not a vailure because the validation function is optionalcontinueexcept Exception as exc:errors.append({'type': 'EXCEPTION_DURING_VALIDATION','message': 'An exception was raised during validation: {}'.format(exc),'property_value': response_property_value})if not is_valid:errors.append({'type': 'VALIDATION_FAILIRE','message': 'validation failed for prop {} with validation func {} resulting in: {}'.format(prop,validation_func.__name__,is_valid),'property_value': response_property_value})return errorserrors = []if isinstance(response, Sequence):for dictionary_obj in response:errors.extend(verify_properties(dictionary_obj, props))else:errors = verify_properties(response, props)return errorsdef published_events_have_ticket_classes(self, pages=None):published_events = self.get_events(pages=pages,params={# 'status': 'live,started,ended,completed','expand': 'ticket_classes'})errors = self.verify_response_properties(published_events, {'ticket_classes': True})is_ok = not bool(errors)return (is_ok, len(published_events), errors)pagination = response_json.pop('pagination', {})current_page_number = int(pagination.get('page_number', 0))next_page = current_page_number + 1has_more_items = bool(pagination.get('has_more_items'))continuation_token = pagination.get('continuation')self.eventbrite_url_format_str.format(path=path),while has_more_items and pages <= next(iteration_counter):parameters = dict(continuation=continuation_token) if continuation_token else dict(page=next_page)has_more_items = Trueiteration_counter = itertools.count()pages = pages or 0headers = self.base_headers()def post_ticket_classes_to_event_legacy(self, event_id, **kwargs):path = 'events/{event_id}/ticket_classes/'.format(event_id=event_id)headers = self.base_headers()headers.update(kwargs.pop('headers', {}))params = kwargs.pop('params', {})return post(self.eventbrite_url_format_str.format(path=path),headers=headers,params=params,**kwargs)try:self.organization_id = self._get_organization_id()except (KeyError, IndexError, AttributeError) as exc:print(self.token, exc)self.organization_id = Nonedef is_legacy_user(self):return not bool(self.organization_id)def _get_organization_id(self):api_response = get(self.base_url + 'users/me/organizations/',headers=self.base_headers())if not api_response.ok:raise EventbriteAPIException('Getting organization information failed')return api_response.json()['organizations'][0]['id']def post_ticket_classes_to_event(self, event_id, **kwargs):if self.is_legacy_user():return self.post_ticket_classes_to_event_legacy(self, event_id, **kwargs)path = '{base_url}events/{event_id}/ticket_classes/'.format(base_url=self.base_url, event_id=event_id)headers = self.base_headers()headers.update(kwargs.pop('headers', {}))params = kwargs.pop('params', {})return post(path,headers=headers,params=params,**kwargs)self.base_headers = lambda: {'Authorization': 'Bearer {}'.format(self.token)}self.organization_id = Noneself.token = Noneself.reset_token(credentials=credentials)self.eventbrite_url_format_str = '{base_url}{organization_base}{path}'.format(base_url=self.base_url,organization_base='organizations/{}/'.format(self.organization_id) or '',path='{path}')def __init__(self, environment=None, credentials=None):self.environment = environment or 'qa').stdout.read().decode('utf-8').strip()account for account in lastpass_accounts).stdout.read().decode('utf-8').split('\n')class EventbriteAPIException(Exception):passfrom requests import get, post # noqa: F401from datetime import datetime # noqa: F401import itertoolsimport json # noqa: F401
This is the IPython startup directory.py and .ipy files in this directory will be run *prior* to any code or files specifiedvia the exec_lines or exec_files configurables whenever you load this profile.Files will be run in lexicographical order, so you can control the execution order of fileswith a prefix, e.g.::00-first.py50-middle.py99-last.ipy
# This file contains fish universal variable definitions.# VERSION: 3.0SETUVAR __fish_classic_git_prompt_initialized:\x1dSETUVAR __fish_init_2_39_8:\x1dSETUVAR __fish_init_2_3_0:\x1dSETUVAR fish_color_autosuggestion:555\x1ebrblackSETUVAR fish_color_cancel:\x2drSETUVAR fish_color_command:\x2d\x2dboldSETUVAR fish_color_comment:redSETUVAR fish_color_cwd:greenSETUVAR fish_color_cwd_root:redSETUVAR fish_color_end:brmagentaSETUVAR fish_color_error:brredSETUVAR fish_color_escape:bryellow\x1e\x2d\x2dboldSETUVAR fish_color_history_current:\x2d\x2dboldSETUVAR fish_color_host:normalSETUVAR fish_color_match:\x2d\x2dbackground\x3dbrblueSETUVAR fish_color_normal:normalSETUVAR fish_color_operator:bryellowSETUVAR fish_color_param:cyanSETUVAR fish_color_quote:yellowSETUVAR fish_color_redirection:brblueSETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblackSETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblackSETUVAR fish_color_status:redSETUVAR fish_color_user:brgreenSETUVAR fish_color_valid_path:\x2d\x2dunderlineSETUVAR fish_greeting:Welcome\x20to\x20fish\x2c\x20the\x20friendly\x20interactive\x20shellSETUVAR fish_pager_color_completion:\x1dSETUVAR fish_pager_color_description:B3A06D\x1eyellowSETUVAR fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderlineSETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyanSETUVAR fish_user_paths:/usr/local/opt/fzf/bin
function __fish_using_commandset cmd (commandline -opc)if [ (count $cmd) -eq (count $argv) ]for i in (seq (count $argv))if [ $cmd[$i] != $argv[$i] ]return 1endendreturn 0endreturn 1endcomplete -c rustup -n "__fish_using_command rustup" -s v -l verbose -d 'Enable verbose output'complete -c rustup -n "__fish_using_command rustup" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup" -f -a "show" -d 'Show the active and installed toolchains'complete -c rustup -n "__fish_using_command rustup" -f -a "install" -d 'Update Rust toolchains'complete -c rustup -n "__fish_using_command rustup" -f -a "uninstall" -d 'Uninstall Rust toolchains'complete -c rustup -n "__fish_using_command rustup" -f -a "update" -d 'Update Rust toolchains and rustup'complete -c rustup -n "__fish_using_command rustup" -f -a "default" -d 'Set the default toolchain'complete -c rustup -n "__fish_using_command rustup" -f -a "toolchain" -d 'Modify or query the installed toolchains'complete -c rustup -n "__fish_using_command rustup" -f -a "target" -d 'Modify a toolchain\'s supported targets'complete -c rustup -n "__fish_using_command rustup" -f -a "component" -d 'Modify a toolchain\'s installed components'complete -c rustup -n "__fish_using_command rustup" -f -a "override" -d 'Modify directory toolchain overrides'complete -c rustup -n "__fish_using_command rustup" -f -a "run" -d 'Run a command with an environment configured for a given toolchain'complete -c rustup -n "__fish_using_command rustup" -f -a "which" -d 'Display which binary will be run for a given command'complete -c rustup -n "__fish_using_command rustup" -f -a "doc" -d 'Open the documentation for the current toolchain'complete -c rustup -n "__fish_using_command rustup" -f -a "man" -d 'View the man page for a given command'complete -c rustup -n "__fish_using_command rustup" -f -a "self" -d 'Modify the rustup installation'complete -c rustup -n "__fish_using_command rustup" -f -a "telemetry" -d 'rustup telemetry commands'complete -c rustup -n "__fish_using_command rustup" -f -a "set" -d 'Alter rustup settings'complete -c rustup -n "__fish_using_command rustup" -f -a "completions" -d 'Generate completion scripts for your shell'complete -c rustup -n "__fish_using_command rustup" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'complete -c rustup -n "__fish_using_command rustup show" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup show" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup install" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup install" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup uninstall" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup uninstall" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup update" -l no-self-update -d 'Don\'t perform self update when running the `rustup` command'complete -c rustup -n "__fish_using_command rustup update" -l force -d 'Force an update, even if some components are missing'complete -c rustup -n "__fish_using_command rustup update" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup update" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup default" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup default" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup toolchain" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup toolchain" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup toolchain" -f -a "list" -d 'List installed toolchains'complete -c rustup -n "__fish_using_command rustup toolchain" -f -a "install" -d 'Install or update a given toolchain'complete -c rustup -n "__fish_using_command rustup toolchain" -f -a "uninstall" -d 'Uninstall a toolchain'complete -c rustup -n "__fish_using_command rustup toolchain" -f -a "link" -d 'Create a custom toolchain by symlinking to a directory'complete -c rustup -n "__fish_using_command rustup toolchain" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'complete -c rustup -n "__fish_using_command rustup toolchain list" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup toolchain list" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup toolchain install" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup toolchain install" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup toolchain uninstall" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup toolchain uninstall" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup toolchain link" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup toolchain link" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup toolchain help" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup toolchain help" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup target" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup target" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup target" -f -a "list" -d 'List installed and available targets'complete -c rustup -n "__fish_using_command rustup target" -f -a "add" -d 'Add a target to a Rust toolchain'complete -c rustup -n "__fish_using_command rustup target" -f -a "remove" -d 'Remove a target from a Rust toolchain'complete -c rustup -n "__fish_using_command rustup target" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'complete -c rustup -n "__fish_using_command rustup target list" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`'complete -c rustup -n "__fish_using_command rustup target list" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup target list" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup target add" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`'complete -c rustup -n "__fish_using_command rustup target add" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup target add" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup target remove" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`'complete -c rustup -n "__fish_using_command rustup target remove" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup target remove" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup target help" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup target help" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup component" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup component" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup component" -f -a "list" -d 'List installed and available components'complete -c rustup -n "__fish_using_command rustup component" -f -a "add" -d 'Add a component to a Rust toolchain'complete -c rustup -n "__fish_using_command rustup component" -f -a "remove" -d 'Remove a component from a Rust toolchain'complete -c rustup -n "__fish_using_command rustup component" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'complete -c rustup -n "__fish_using_command rustup component list" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`'complete -c rustup -n "__fish_using_command rustup component list" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup component list" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup component add" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`'complete -c rustup -n "__fish_using_command rustup component add" -l targetcomplete -c rustup -n "__fish_using_command rustup component add" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup component add" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup component remove" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`'complete -c rustup -n "__fish_using_command rustup component remove" -l targetcomplete -c rustup -n "__fish_using_command rustup component remove" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup component remove" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup component help" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup component help" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup override" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup override" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup override" -f -a "list" -d 'List directory toolchain overrides'complete -c rustup -n "__fish_using_command rustup override" -f -a "set" -d 'Set the override toolchain for a directory'complete -c rustup -n "__fish_using_command rustup override" -f -a "unset" -d 'Remove the override toolchain for a directory'complete -c rustup -n "__fish_using_command rustup override" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'complete -c rustup -n "__fish_using_command rustup override list" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup override list" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup override set" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup override set" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup override unset" -l path -d 'Path to the directory'complete -c rustup -n "__fish_using_command rustup override unset" -l nonexistent -d 'Remove override toolchain for all nonexistent directories'complete -c rustup -n "__fish_using_command rustup override unset" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup override unset" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup override help" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup override help" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup run" -l install -d 'Install the requested toolchain if needed'complete -c rustup -n "__fish_using_command rustup run" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup run" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup which" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup which" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup doc" -l book -d 'The Rust Programming Language book'complete -c rustup -n "__fish_using_command rustup doc" -l std -d 'Standard library API documentation'complete -c rustup -n "__fish_using_command rustup doc" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup doc" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup man" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`'complete -c rustup -n "__fish_using_command rustup man" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup man" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup self" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup self" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup self" -f -a "update" -d 'Download and install updates to rustup'complete -c rustup -n "__fish_using_command rustup self" -f -a "uninstall" -d 'Uninstall rustup.'complete -c rustup -n "__fish_using_command rustup self" -f -a "upgrade-data" -d 'Upgrade the internal data format.'complete -c rustup -n "__fish_using_command rustup self" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'complete -c rustup -n "__fish_using_command rustup self update" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup self update" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup self uninstall" -s ycomplete -c rustup -n "__fish_using_command rustup self uninstall" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup self uninstall" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup self upgrade-data" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup self upgrade-data" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup self help" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup self help" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup telemetry" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup telemetry" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup telemetry" -f -a "enable" -d 'Enable rustup telemetry'complete -c rustup -n "__fish_using_command rustup telemetry" -f -a "disable" -d 'Disable rustup telemetry'complete -c rustup -n "__fish_using_command rustup telemetry" -f -a "analyze" -d 'Analyze stored telemetry'complete -c rustup -n "__fish_using_command rustup telemetry" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'complete -c rustup -n "__fish_using_command rustup telemetry enable" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup telemetry enable" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup telemetry disable" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup telemetry disable" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup telemetry analyze" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup telemetry analyze" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup telemetry help" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup telemetry help" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup set" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup set" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup set" -f -a "default-host" -d 'The triple used to identify toolchains when not specified'complete -c rustup -n "__fish_using_command rustup set" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'complete -c rustup -n "__fish_using_command rustup set default-host" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup set default-host" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup set help" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup set help" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup completions" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup completions" -s V -l version -d 'Prints version information'complete -c rustup -n "__fish_using_command rustup help" -s h -l help -d 'Prints help information'complete -c rustup -n "__fish_using_command rustup help" -s V -l version -d 'Prints version information'
function __fish_using_commandset cmd (commandline -opc)if [ (count $cmd) -eq (count $argv) ]for i in (seq (count $argv))if [ $cmd[$i] != $argv[$i] ]return 1endendreturn 0endreturn 1endcomplete -c rg -n "__fish_using_command rg" -s e -l regexp -d "Use pattern to search."complete -c rg -n "__fish_using_command rg" -l color -d "When to use color. [default: auto]" -r -f -a "never auto always ansi"complete -c rg -n "__fish_using_command rg" -l colors -d "Configure color settings and styles."complete -c rg -n "__fish_using_command rg" -s E -l encoding -d "Specify the text encoding of files to search."complete -c rg -n "__fish_using_command rg" -s g -l glob -d "Include or exclude files/directories."complete -c rg -n "__fish_using_command rg" -l iglob -d "Include or exclude files/directories case insensitively."complete -c rg -n "__fish_using_command rg" -s t -l type -d "Only search files matching TYPE."complete -c rg -n "__fish_using_command rg" -s T -l type-not -d "Do not search files matching TYPE."complete -c rg -n "__fish_using_command rg" -s A -l after-context -d "Show NUM lines after each match."complete -c rg -n "__fish_using_command rg" -s B -l before-context -d "Show NUM lines before each match."complete -c rg -n "__fish_using_command rg" -s C -l context -d "Show NUM lines before and after each match."complete -c rg -n "__fish_using_command rg" -l context-separator -d "Set the context separator string. [default: --]"complete -c rg -n "__fish_using_command rg" -l dfa-size-limit -d "The upper size limit of the generated dfa."complete -c rg -n "__fish_using_command rg" -s f -l file -d "Search for patterns from the given file."complete -c rg -n "__fish_using_command rg" -l ignore-file -d "Specify additional ignore files."complete -c rg -n "__fish_using_command rg" -s m -l max-count -d "Limit the number of matches."complete -c rg -n "__fish_using_command rg" -l max-filesize -d "Ignore files larger than NUM in size."complete -c rg -n "__fish_using_command rg" -l maxdepth -d "Descend at most NUM directories."complete -c rg -n "__fish_using_command rg" -l path-separator -d "Path separator to use when printing file paths."complete -c rg -n "__fish_using_command rg" -s r -l replace -d "Replace matches with string given."complete -c rg -n "__fish_using_command rg" -l regex-size-limit -d "The upper size limit of the compiled regex."complete -c rg -n "__fish_using_command rg" -s j -l threads -d "The approximate number of threads to use."complete -c rg -n "__fish_using_command rg" -s M -l max-columns -d "Don't print lines longer than this limit in bytes."complete -c rg -n "__fish_using_command rg" -l type-add -d "Add a new glob for a file type."complete -c rg -n "__fish_using_command rg" -l type-clear -d "Clear globs for given file type."complete -c rg -n "__fish_using_command rg" -l files -d "Print each file that would be searched."complete -c rg -n "__fish_using_command rg" -l type-list -d "Show all supported file types."complete -c rg -n "__fish_using_command rg" -s a -l text -d "Search binary files as if they were text."complete -c rg -n "__fish_using_command rg" -s c -l count -d "Only show count of matches for each file."complete -c rg -n "__fish_using_command rg" -s F -l fixed-strings -d "Treat the pattern as a literal string."complete -c rg -n "__fish_using_command rg" -s i -l ignore-case -d "Case insensitive search."complete -c rg -n "__fish_using_command rg" -s n -l line-number -d "Show line numbers."complete -c rg -n "__fish_using_command rg" -s N -l no-line-number -d "Suppress line numbers."complete -c rg -n "__fish_using_command rg" -s q -l quiet -d "Do not print anything to stdout."complete -c rg -n "__fish_using_command rg" -s u -l unrestricted -d "Reduce the level of "smart" searching."complete -c rg -n "__fish_using_command rg" -s v -l invert-match -d "Invert matching."complete -c rg -n "__fish_using_command rg" -s w -l word-regexp -d "Only show matches surrounded by word boundaries."complete -c rg -n "__fish_using_command rg" -s x -l line-regexp -d "Only show matches surrounded by line boundaries."complete -c rg -n "__fish_using_command rg" -l column -d "Show column numbers"complete -c rg -n "__fish_using_command rg" -l debug -d "Show debug messages."complete -c rg -n "__fish_using_command rg" -s l -l files-with-matches -d "Only show the paths with at least one match."complete -c rg -n "__fish_using_command rg" -l files-without-match -d "Only show the paths that contains zero matches."complete -c rg -n "__fish_using_command rg" -s H -l with-filename -d "Show file name for each match."complete -c rg -n "__fish_using_command rg" -l no-filename -d "Never show the file name for a match."complete -c rg -n "__fish_using_command rg" -l heading -d "Show matches grouped by each file."complete -c rg -n "__fish_using_command rg" -l no-heading -d "Don't group matches by each file."complete -c rg -n "__fish_using_command rg" -l hidden -d "Search hidden files and directories."complete -c rg -n "__fish_using_command rg" -s L -l follow -d "Follow symbolic links."complete -c rg -n "__fish_using_command rg" -l mmap -d "Searching using memory maps when possible."complete -c rg -n "__fish_using_command rg" -l no-messages -d "Suppress all error messages."complete -c rg -n "__fish_using_command rg" -l no-mmap -d "Never use memory maps."complete -c rg -n "__fish_using_command rg" -l no-ignore -d "Don't respect ignore files."complete -c rg -n "__fish_using_command rg" -l no-ignore-parent -d "Don't respect ignore files in parent directories."complete -c rg -n "__fish_using_command rg" -l no-ignore-vcs -d "Don't respect VCS ignore files"complete -c rg -n "__fish_using_command rg" -s 0 -l null -d "Print NUL byte after file names"complete -c rg -n "__fish_using_command rg" -s o -l only-matching -d "Print only matched parts of a line."complete -c rg -n "__fish_using_command rg" -s p -l pretty -d "Alias for --color always --heading --line-number."complete -c rg -n "__fish_using_command rg" -s s -l case-sensitive -d "Search case sensitively."complete -c rg -n "__fish_using_command rg" -s S -l smart-case -d "Smart case search."complete -c rg -n "__fish_using_command rg" -l sort-files -d "Sort results by file path. Implies --threads=1."complete -c rg -n "__fish_using_command rg" -l vimgrep -d "Show results in vim compatible format."complete -c rg -n "__fish_using_command rg" -s h -l help -d "Prints help information. Use --help for more details."complete -c rg -n "__fish_using_command rg" -s V -l version -d "Prints version information"
set -x PYENV_ROOT $HOME/.pyenvset -x PYENV_SHELL fishset -x PYTHON_2_PATH $PYENV_ROOT/versions/misc2/binset -x PYTHON_3_PATH $PYENV_ROOT/versions/misc3/binset -x RUSTPATH $HOME/.cargo/binset -x FZF_DEFAULT_COMMAND 'fd --type f --follow --hidden --exclude .git'set -x FZF_CTRL_T_COMMAND $FZF_DEFAULT_COMMANDset -x PATH $RUSTPATH $PYTHON_2_PATH $PYTHON_3_PATH $PYENV_ROOT/bin $PYENV_ROOT/shims $HOME/.local/bin $DOTFILES/bin /usr/local/bin $PATHset -x WORKON_HOME $PYENV_ROOT/versions/fish_vi_key_bindingsendset -x EVENTBRITE ~/eventbrite_github/eventbriteset -x BAY_HOME $EVENTBRITE/docker-dev# source private variables if existset -x PRIVATE_VARIABLES_FILE "$DOTFILES/fish/private_variables.fish"test -e "$PRIVATE_VARIABLES_FILE"; and source $PRIVATE_VARIABLES_FILEset -x EDITOR emacsclient -c# source other misc variables if existset -x MISC_VARIABLES_FILE "$DOTFILES/fish/misc_variables.fish"test -e "$MISC_VARIABLES_FILE"; and source $MISC_VARIABLES_FILEset -l ALLOW_VI_IN_TERM 'xterm-256color' 'screen-256color'if contains $TERM $ALLOW_VI_IN_TERMset -x DOTFILES ~/dotfiles
function update_dotfilesset do_git_pull trueset force_update_installed_workflows falsefor arg in $argvswitch $argcase --force-update-workflowsset force_update_installed_workflows truecase --no-git --no-git-pull --no-pullset do_git_pull falseendendpushd (pwd)if eval $do_git_pull# get latest version from githubcd $DOTFILESset curr_branch (git rev-parse --abbrev-ref HEAD)git stash > /dev/null 2>&1git checkout master > /dev/null 2>&1git pull > /dev/null 2>&1; and echo "pulling the latest from github..."git checkout "$curr_branch" > /dev/null 2>&1git stash pop > /dev/null 2>&1popdendif test (uname) = "Darwin"set workflows_path $DOTFILES/osx/automator_workflows/set os_services_path ~/Library/Services# if force update all workflowsif eval $force_update_installed_workflows# install all osx automator workflowscp -r $workflows_path $os_services_path; and echo "installing all available workflows"else# install only the workflows that aren't already installedfor wf in (ls $workflows_path)if not contains "$wf" (ls $os_services_path)cp -r "$workflows_path/$wf" $os_services_path; and echo "installing new workflow: $wf"endendendendend
function fish_prompt --description 'Write out the prompt'set -l last_status $statusend# what actually gets printed to the screenecho -ns (set_color $fish_color_user) "$USER"echo -ns $normal @ (set_color $fish_color_host) (prompt_hostname)echo -ns $normal ' ' (set_color $color_cwd) (prompt_pwd)echo -ns $normal (__fish_vcs_prompt)echo $normalecho -s "└--" $prompt_status "-"$suffix " "set -l prompt_statusif test $last_status -ne 0set prompt_status ' ' (set_color $fish_color_status) "[$last_status]" "$normal"endset -l color_cwdset -l prefixset -l suffixswitch $USERcase root toorif set -q fish_color_cwd_rootset color_cwd $fish_color_cwd_rootelseset color_cwd $fish_color_cwdendset suffix '#'case '*'set color_cwd $fish_color_cwdset suffix '$'end# initialize our new variablesif not set -q __fish_classic_git_prompt_initializedset -qU fish_color_useror set -U fish_color_user -o greenset -qU fish_color_hostor set -U fish_color_host -o cyanset -qU fish_color_statusor set -U fish_color_status redset -U __fish_classic_git_prompt_initializedendendfunction __fish_repaint_bind_mode --on-variable fish_key_bindings --description "Event handler; repaint when fish_key_bindings changes"if status --is-interactivecommandline -f repaint ^/dev/nullendendfunction __fish_repaint_host --on-variable fish_color_host --description "Event handler, repaint when fish_color_host changes"if status --is-interactivecommandline -f repaint ^/dev/nullendendfunction __fish_repaint_status --on-variable fish_color_status --description "Event handler; repaint when fish_color_status changes"if status --is-interactivecommandline -f repaint ^/dev/nullendendfunction __fish_repaint_user --on-variable fish_color_user --description "Event handler, repaint when fish_color_user changes"if status --is-interactivecommandline -f repaint ^/dev/nullendend# Hack; fish_config only copies the fish_prompt function (see #736)if not set -q -g __fish_classic_git_functions_definedset -g __fish_classic_git_functions_definedset -l normal (set_color normal)
function colorizeset STRINGset COLOR $normalset BOLD_OUTPUT Falsefor arg in $argv# echo 'arg' $arg# echoswitch $argcase ls listset_color -ccase --bold -bset BOLD_OUTPUT Truecase '--color-*'set COLOR (echo $arg | rg '(\-\-color\-)(\w+)' --replace '$2')case '*'set STRING $STRING $argendendif echo (set_color -c) | grep -qw "$COLOR"set COLOR_ESC_SEQ (set_color $COLOR)if eval $BOLD_OUTPUTset COLOR_ESC_SEQ (set_color -o $COLOR)endecho $COLOR_ESC_SEQ $STRING (set_color $normal)elseerror_message "$COLOR is not an available color"endendset_color normal
function ebmysqlset host $EB_MYSQL_PROD_HOSTset user $EB_OKTA_USERset lpass_lookup oktaset args_to_passset index 2set last_was_flag 0for flag in $argvset arg $argv[$index]set arg_is_flag 1set arg_is_flag 0endswitch $flagcase --lpass --lastpass --last-passif test $arg_is_flag -eq 0set lpass_lookup $argelseerror_message "--lpass --lastpass --last-pass flag requires an argument"endcase -p --pass --passwordif test $arg_is_flag -eq 0set password $argelseerror_message "-p --pass --password flag requires an argument"return 1endcase -h --hostif test $arg_is_flag -eq 0elseerror_message "-h and --host flag requires an argument"return 1endcase -u --userif test $arg_is_flag -eq 0set user $argelseerror_message "-u --user flag requires an argument"return 1endcase '*'endset index (math $index + 1)end# if password is unset, get from lpassif test $password = ""set password (script_lpass $lpass_lookup)endendif isatty stdoutecho "preparing to log into mysql"echo "$host @ $user"echo "..."end/usr/local/bin/mysql $args_to_pass -h "$host" -u "$user" --password="$password"# if user is unset, ask for input interactively# this won't happen if your env variables are set properlyif test $user = ""echo "Please input your user name for mysql:$host"read userendif test $last_was_flag -eq 0set args_to_pass $args_to_pass $flagelseset last_was_flag 0end# pass these directly to mysql unless they are arguments to the flags handled aboveset last_was_flag 1set last_was_flag 1set tmp_host (find_in_env $arg)set host $tmp_hostif test $tmp_host = ""set host $argend# look up the host url from the environment, if none, use whatever is passed here directlyset last_was_flag 1# don't lookup the password with lpass, just use whatever is passed in here and send it to mysql directlyset last_was_flag 1# if lpass flag not used, defaulted to looking up okta, unless password is passed in with the -p flagif not echo $arg | grep -qE '^\-+'# parse arguments into something that can be passed to mysqlset password ""
function error_messageset ERR_STRINGset RING_ALERT_BELL Falseset BOLD_OUTPUT Falseset ERR_COLOR 'red'set NO_COLOR Falsefor arg in $argvswitch $argcase --alert -aset RING_ALERT_BELL Truecase --bold -bset BOLD_OUTPUT Truecase --warn -wset ERR_COLOR 'yellow'case --no-colorset NO_COLOR Truecase '*'set ERR_STRING $ERR_STRING $argendendset ERR_MSG $ERR_STRINGif not eval $NO_COLORset COLOR_FLAGS "--color-$ERR_COLOR"if eval $BOLD_OUTPUTset COLOR_FLAGS '--bold' $COLOR_FLAGSendset ERR_MSG (colorize $COLOR_FLAGS $ERR_STRING)endecho "$ERR_MSG" > /dev/stderrif eval $RING_ALERT_BELLecho -ne '\a'endend
function sync_personal_email# get new mail from imap.fastmail.comif test (hostname) = "notmuch-thesogu"elsessh thesogu "mbsync fastmail" > /dev/nullendif test $status -eq 0# index new mailnotmuch new > /dev/null ^ /dev/stdout | grep -v "Note: Ignoring non-mail file:" | tee /dev/stderr# INFO: notmuch tags all new mail with: inbox new unread# add personal tag# add tags to things that I want to call out, but still see in my inbox# archive stuff that's important but I don't want in inbox# receipts and order confirmationsnotmuch tag -inbox +receipts -- tag:new AND tag:personal "(receipt or confirmation or purchase or payment)" and "(from:lyft or form:uber or from:square or from:amazon or homedepot or paypal)" not subject:review# filter out cruft that I don't really want to seenotmuch tag -inbox +social_media_notifications -- tag:new AND tag:personal "(from:@twitter.com or from:@facebookmail.com)"# remove new tag from everythingnotmuch tag -new tag:new# do clean up# tag messages from work email as sent# remove inbox tag from emails that I've replied toendend# notmuch tag -inbox -unread -- tag:inbox AND tag:repliednotmuch tag -inbox -unread +sent -- from:chris@thesogu.com AND tag:personal# add tags to things I want to see, but not in my inboxset LOW_PRIORITY_SEARCH "(tag:personal AND tag:new) AND (from:spam@spam.spam"for phrase in (cat "$DOTFILES/low_priority_list")set LOW_PRIORITY_SEARCH $LOW_PRIORITY_SEARCH " OR from:$phrase" # the leading space is intentionalendset LOW_PRIORITY_SEARCH $LOW_PRIORITY_SEARCH ") AND (not tag:receipt)"notmuch tag +low_priority -inbox -new -- "$SPAM_SEARCH"# filter out spamset SPAM_SEARCH "(tag:personal AND tag:new) AND (from:spam@spam.spam"for email in (cat "$DOTFILES/email_spam_list" "$DOTFILES/personal_email_filter")set SPAM_SEARCH $SPAM_SEARCH " OR from:$email" # the leading space is intentionalendset SPAM_SEARCH $SPAM_SEARCH ") AND (not tag:receipt)"notmuch tag +spam -inbox -new -- "$SPAM_SEARCH"notmuch tag +personal -- tag:new AND "(from:$PERSONAL_EMAIL or to:$PERSONAL_EMAIL or from:$PERSONAL_GMAIL or to:%@gmail.com)"mbsync fastmail > /dev/null
function sync_eventbrite_email# get new mail from imap.gmail.comif test $status -eq 0# index new mailnotmuch new > /dev/null ^ /dev/stdout | grep -v "Note: Ignoring non-mail file:" | tee /dev/stderr# INFO: notmuch tags all new mail with: inbox new unread# add tags to things that I want to call out, but still see in my inbox# add tags to things I want to see, but not in my inboxnotmuch tag +eventbrite_github -inbox -- tag:new from:notifications@github.com subject:eventbrite# filter out cruft that I don't really want to seenotmuch tag -inbox +deleted +sentry -- tag:new from:sentry@eventbrite.com or from:site-errors@eventbrite.comnotmuch tag -inbox +low_priority +jenkins -- tag:new from:eng-ops@eventbrite.com# do clean up# tag messages from work email as sent# remove inbox tag from emails that I've replied to# remove new tag from everythingnotmuch tag -new -- tag:new AND tag:eventbriteendend# notmuch tag -inbox -unread -- tag:inbox tag:replied tag:newnotmuch tag -inbox -unread +sent -- from:$EVENTBRITE_EMAIL tag:newnotmuch tag -inbox +low_priority -- tag:new from:jira@eventbrite.com not "$MY_NAME"notmuch tag +api_support -- tag:new "(to:api@eventbrite.com OR to:eventbrite-api@googlegroups.com)"notmuch tag +jira_mention -- tag:new from:jira@eventbrite.com "('mentioned you on' OR 'Chris Cummings')"# add eventbrite tagnotmuch tag +eventbrite -- tag:new "(to:@eventbrite.com or from:$EVENTBRITE_EMAIL_PATTERN or to:@evbqa.com or from:@evbqa.com)"# filter out spamset SPAM_SEARCH "(tag:eventbrite AND tag:new) AND (from:spam@spam.spam"for email in (cat "$DOTFILES/email_spam_list" "$DOTFILES/eventbrite_email_filter")set SPAM_SEARCH $SPAM_SEARCH " OR from:$email" # the leading space is intentionalendset SPAM_SEARCH $SPAM_SEARCH ")"mbsync ebmail > /dev/nullelsessh thesogu "mbsync ebmail" > /dev/nullendif test (hostname) = "notmuch-thesogu"
function ebapiset host $EB_API_QA_URLset host_pattern qaset expansionsset parametersset pathset tokenset args_to_passfor arg in $argvswitch $argcase '--host=*' '--env=*'set host_pattern (echo $arg | cut -d '=' -f 2)set host (find_in_env "api.*$host_pattern")if test $host = ""set host $argendcase '-e=*' '--expansions=*'set expansions (echo $arg | cut -d '=' -f 2)case '-t=*' '--token=*'set token (echo $arg | cut -d '=' -f 2)case '-p=*' '--param=*' '--params=*' '--parameters=*'set parameters "$parameters&"(echo $arg | rg '(\-{1,2}p\w*=)(.*)' -o --replace '$2')case '/*/'set path $argcase '*'set args_to_pass $args_to_pass $argendendset token_pattern "$host_pattern.*token"while not test -n "$token"set token (script_lpass $token_pattern)if not test -n "$token"echo "A token can't be found in last pass with pattern: '$token_pattern'"echo "try searching for your token in lastpass"echo "or CTRL C to exit"read token_pattern -P '>>> 'endendendset url "$host$path?expand=$expansions$parameters"json_request $url $args_to_pass -H "Authorization: Bearer $token"case '--help'echo USAGE:echo 'ebapi [ENDPOINT] [FLAGS]'echo 'FLAGS AVAILABLE: -h -p -e -t'echo 'host, parameter, expansion, token'echo 'any other arguments are passed directly to curl'return 0
function attach_or_new_tmux_sessionset session_name miscset confirmed Falsefor arg in $argvswitch $argcase -f --forceset confirmed Truecase '*'if not echo $arg | grep -e '^-'set session_name (to_lower $arg)endendendif not eval $confirmedecho "attach to tmux session: $session_name? [Y/n]"read user_inputswitch (to_lower $user_input)case y yes 1set confirmed Truecase '*'return 1 # indicates failure to attachendendif eval $confirmedif is_attached_tmux_sessionif not tmux has-session -t "$session_name" > /dev/null ^&1tmux new-session -ds $session_nameendecho "to avoid nesting sessions, choose the $session_name session with C-b s"elseecho "attaching to tmux session: $session_name"tmux new-session -As "$session_name"endendend
function wsset query ""set search_engine_url 'https://duckduckgo.com/?q='set search_engine 'duckduckgo'set output "gui_browser"for arg in $argvcase --url -uset output "url"case --terminal-browser -tset output "w3m"case --browser -bset output "gui_browser"case --googleset search_engine_url 'https://google.com/?q='set search_engine 'google'set search_engine_url 'https://duckduckgo.com/?q='set search_engine 'duckduckgo'case '*'endendset url_regex '^\s+(https?://)?(www.)?([a-z]+\.){1,3}[a-z]{2,4}(/.*)?'set results_temp_file (mktemp /tmp/ws_search_result.XXXXXXXXXX)w3m -dump "$search_engine_url$query" > $results_temp_fileset user_selection (cat $results_temp_file | rg "$url_regex" | sed 's/ *//g' | fzf --preview "echo {}; echo \"--------------------\"; cat $results_temp_file | rg {} -B 4")if not echo $user_selection | rg -q "https?://"set user_selection "https://$user_selection"endrm $results_temp_fileif test $output = 'url'echo $user_selectionelse if test $output = 'w3m'w3m $user_selectionelse if test $output = 'gui_browser'python -m webbrowser $user_selectionelseecho $user_selectionendendecho "Opening $search_engine in $output"echo "query: $query" | sed 's/%20/ /g'if test $query = ""set query $argelseset query "$query%20$arg"endcase --duckduckgo --ddgswitch $arg
function pyactivate --description 'activate a pyenv virtualenv by name'set VENV_NAMEfor arg in $argvswitch $argcase --helpecho 'USAGE:'echo " pyactivate [venv_name] activate a pyenv-virtualenv by name"echo ' pyactivate ls list available pyenv-virtualenvs'echoecho ' options:'echo ' --help display this message'return 0case ls listpyenv versionsreturn 0case '--*'error_message --warn --bold "$arg is an unrecognized flag"return 9case '*'if test -n $VENV_NAMEset VENV_NAME $argendendendif not test -n "$VENV_NAME"error_message --alert 'virtual environment name is a required arguemnt'return 1elseif echo (pyenv versions) | grep -qw "$VENV_NAME"set VENV_DIR "$PYENV_ROOT/versions/$VENV_NAME"source $VENV_DIR/bin/activate.fishelseerror_message 'virtual env does not exist'return 2endendend
function new_lines_count# if there are arguments, don't read from stdin, pipe them throughif test (count $argv) -ne 0if test -f "$argv"cat "$argv" | wc -l | rg -o '\d{1,}'elseecho "$argv" | wc -l | rg -o '\d{1,}'endelsewc -l | rg -o '\d{1,}'endend
endfunction emacs --description 'convenience wrapper for starting an emacs client and server'# open emacs in gui by defaultset TERMINAL_EMACS falseset passed_argsfor arg in $argvswitch $argcase -t --terminalset TERMINAL_EMACS truecase '*'set passed_args $passed_args $argendend/usr/local/bin/emacs --daemon ^ /dev/null > /dev/nullendif eval $TERMINAL_EMACSelseendif not ps aux | grep -v grep | grep --silent 'emacsclient \-c'# create frame if one doesn't exist otherwise use existing gui frameset passed_args -c $passed_argsend/usr/local/bin/emacsclient $passed_args > /dev/null &/usr/local/bin/emacsclient -t $passed_argsif not ps aux | grep -v grep | grep --silent 'emacs.* \-\-daemon'# if there is not an emacs server running, start one
function ebprestoerror_if_not_set EB_PRESTO_SERVER EB_PRESTO_USERif test $status -ne 0return $statusendset PRESTO_PATH /usr/local/bin/prestoif not test -e $PRESTO_PATHerror_message "presto does not appear to be installed at $PRESTO_PATH"endeval $PRESTO_PATH --server $EB_PRESTO_SERVER --user $EB_PRESTO_USER $argvend
function ebapi_paginateset results_file (mktemp /tmp/ebapi_paginate.XXXXXX)ebapi $argv > $results_fileset pagination_object (echo $results_file | jq -c '.pagination')set continuation_token (echo $pagination_object | jq '.continuation')rm $results_fileend
function cdfinderset -l current_path (run_apple_script 'tell application "Finder"tryset currFolder to (folder of the front window as alias)on errorset currFolder to (path to home folder as alias)end tryreturn (POSIX path of currFolder)end tell')echo " Finder is at: $current_path, changing directories"cd "$current_path"end
# filter account list by argv, store in tmp_fileset tmp_file (mktemp /tmp/getpass_tmp_file.XXXXXXXXXXXXXXX)lpass ls | rg -i "$argv" > $tmp_fileset match_count (new_lines_count $tmp_file)set lpass_id_regex '\d{5,}'if test $match_count -eq 0echo "Could not find $argv -" (lpass status)return 1else if test $match_count -ge 2# fuzzy find account, pass account id back, lpass finds then copies pass to clipboardlpass show -cp $choiceelselpass show -cp (cat $tmp_file | rg -o $lpass_id_regex)endrm $tmp_fileendset choice (cat $tmp_file | fzf)if test $status -eq 130# fzf was quit without a choicereturn 0endset choice (echo $choice | rg -o $lpass_id_regex)function pass --description 'fuzzy find passwords from lastpass-cli'for arg in $argvswitch $argcase --helpecho 'pass: fuzzy find passwords from lastpass-cli'echo 'USEAGE: pass [pattern]'echo 'Note: most flags will get passed to ripgrep'return 0endend
function copyend# if there are arguments, don't read from stdin, pipe them throughif test (count $argv) -ne 0if test -f "$argv"cat $argv | pbcopyelseecho $argv | pbcopyendelsepbcopyend
function rgvimendendif [ $choice ]/usr/local/bin/nvim "+/"(to_lower $argv) $choiceset choice (rg -il $argv | fzf -0 -1 --ansi --preview "cat {} | rg $argv --context 3")
function prettify_terminal_commandset resultset count 1for arg in $argvecho $argif test $count -gt 1set count (math $count + 1)set next $argv[$count]if test $count -eq 2set result $result (simple_quote $arg)endelse # this should always be the base commandset result $argend# echo $arg \\endfor w in $resultecho $wendend
function find_in_envset fzf_helper_msg "Choose an environment variable"if echo $argv | grep -q .env | rg -i $argv | fzf -1 -0 --header "$fzf_helper_msg" | cut -d '=' -f 2elseenv | fzf -1 -0 --header "$fzf_helper_msg" | cut -d '=' -f 2endend
function nmshow# tag:api_support and tag:api_answered and tag:cx_can_answer and from:support@eventbrite.comendnotmuch-remote show --format=json $argv | jq . | parse_notmuch_email | parsed_email_jq
function require_bin_in_pathset COUNT_NOT_IN_PATH 0for arg in $argvwhich $arg > /dev/nullif test $status -ne 0set COUNT_NOT_IN_PATH (math $COUNT_NOT_IN_PATH + 1)endendreturn $COUNT_NOT_IN_PATHendecho $arg
function script_lpass# if logged out, log inif not lpass status -qendendset result (/usr/local/bin/lpass show -p -G "$argv")if echo $result | grep -iq "multiple matches found"endecho $resultset result (lpass show -p (lpass ls | grep -i -E "$argv" | fzf | rg -o --replace '$1' '\[id: (\d+)\]'))/usr/local/bin/lpass login $EB_LAST_PASS_USER > /dev/null
function rmerror_message "you do not want to delete / or ~... dumbass"return 1end/bin/rm $argvendif echo $argv | grep -qE '(^|\s+)(/|~)\*?($|\s)'
endfunction update_brew_packages --description 'update selected (or all) brew packages'set no_confirm falsefor arg in $argvswitch $argcase --all --force -fset no_confirm truecase --helpecho 'update selected brew packages'echo 'OPTIONS:'echo ' -all, --force -f: update every outdated package without confirmation'return 0endendset outdated_list_tmp_file (mktemp /tmp/outdated_list_tmp_file.XXXXXXXXXXX)brew outdated > $outdated_list_tmp_fileif test (new_lines_count $outdated_list_tmp_file) -ne 0cat outdated_list_tmp_file | xargs brew upgradeelsecat outdated_list_tmp_file | fzf -m -n 1 --tac --header='choose packages to update with tab' | xargs brew upgradeendendrm $outdated_list_tmp_fileif eval $no_confirmbrew update > /dev/null
function simple_quotefor arg in $argvif echo $arg | contains_spaceselseendendendecho $argset should_quote trueendif echo $arg | grep -Eq "$URL_REGEX"set should_quote trueendif eval $should_quoteecho "'$arg'"set should_quote falseerror_if_not_set URL_REGEX
function json_requestenderror_if_bin_not_available jq curl; or return 1set HELP_MSG 'USAGE: json_request [REQUIRED: (URL) ] [OPTIONAL: (ARGS PASSED TO CURL) (OTHER OPTIONAL ARGS) ]REQUIRED ARGUMENTS:* URLOPTIONS:* --dry-run -- dont actually send the request via curl* --log-parse-failures -- cat out non-json responses* --jq="" -- pass arguments, flags, options to jq* --print-curl-command -- pretty print out the resulting command to easily share with others* --share-to-clipboard -- dry run and print resulting command to clipboard* any flag or option for curl -- see `man curl` for detailsEXAMPLES:* json_request https://www.evbqaapi.com/v3/users/me/ -H "Authorization: Bearer SOME-TOKEN"INFO:* every argument is passed directly to curl _except_ the --jq="" argument.* the quoted, space delimited arguments to the right of --jq= are passed directly to jq* uses the curl installed by homebrew if it existsERRORS:* 1 - required arguments are missing* 2 - one of the required commands or functions is not available in the path* 3 - the response cannot be parsed as jsonsee `man curl` and `man jq` for help with flags and options'set CAT_JSON_PARSE_FAILURES falseset CURL_ARGS -sSset DRY_RUN falseset PRINT_CURL_COMMAND_OUT falseset PRINT_TO_CLIPBOARD falseset RETURN_STATUS_CODE 0for arg in $argvswitch $argcase '--help'echo "$HELP_MSG"return 0case '--dry-run'set DRY_RUN truecase '--print-curl-command'set PRINT_CURL_COMMAND_OUT truecase '--share-to-clipboard'set DRY_RUN trueset PRINT_CURL_COMMAND_OUT trueset PRINT_TO_CLIPBOARD truecase '--jq=*'case '--log-parse-failures'set CAT_JSON_PARSE_FAILURES truecase '*'set CURL_ARGS $CURL_ARGS (simple_quote $arg)endendif test (count $CURL_ARGS) -lt 2error_message "missing required argument: URL"return 1endset JQ_ARGS $JQ_ARGS (echo $arg | cut -d '=' -f 2)set JQ_ARGS ""* json_request https://www.evbqaapi.com/v3/users/me/owned_events/ --jq="[.events[] | select(.status == "live")], .pagination"# use homebrew curl if it existsendif eval $PRINT_CURL_COMMAND_OUT# TODO: find a way to format this into something that's easy for someone to copy and paste into# another terminalset pretty_command "$CURL_COMMAND $CURL_ARGS"if eval $PRINT_TO_CLIPBOARDecho $pretty_command | pbcopyelseecho $pretty_commandendendif not eval $DRY_RUNset JSON_FILE (mktemp /tmp/json_request.XXXXXXXXXX)eval $CURL_COMMAND $CURL_ARGS > $JSON_FILE# pretty format json file if can be parsed as jsoncat $JSON_FILE | jq $JQ_ARGS ^ /dev/nullif test $status -ne 0# cat out raw response if cannot be parsed as jsonerror_message "Response could not be parsed from request"error_message -w "$CURL_COMMAND $CURL_ARGS"if eval $CAT_JSON_PARSE_FAILUREScat $JSON_FILEendset RETURN_STATUS_CODE 3endrm $JSON_FILEendreturn $RETURN_STATUS_CODEif test $JQ_ARGS = ""; set JQ_ARGS '.'; endset CURL_COMMAND /usr/local/opt/curl/bin/curlif not test -e $CURL_COMMANDset CURL_COMMAND curl
set RG_ARGSset N_LARGEST 0for arg in $argvswitch $argcase '-n*'if test $num -gt 0set RG_ARGS $RG_ARGS "-c"set N_LARGEST $numendcase '*'set RG_ARGS $RG_ARGS $argendendfrom heapq import nlargestfrom sys import stdinendendif test -e "$PY_FILE"rm $PY_FILEeval $COMMANDfor match in nlargest($N_LARGEST, stdin.readlines(), key=lambda l: l.split(':')[-1]):print(match.strip())" > $PY_FILEset COMMAND "$COMMAND | python $PY_FILE"endif test $USE_FZF -gt 0set FILTER_FILE_NAME 'cut -f 1 -d :'set FZF_COMMAND "fzf --preview 'cat {}'"set COMMAND "$COMMAND | $FILTER_FILE_NAME | $FZF_COMMAND"endset COMMAND "rg $RG_ARGS"if test $N_LARGEST -gt 0set PY_FILE (mktemp /tmp/srch_py.XXXXXXXXXXXXX)printf "case '--print'set USE_FZF 0set -l num (echo $arg | rg --replace '$1' -- '-n(\d+)')set USE_FZF 1function srch -d 'wrapper around ripgrep and fzf. USAGE: find top 5 files by num of matches: $ srch PATTERN -g GLOB -n5'
(define-key notmuch-search-mode-map "r" 'notmuch-search-reply-to-thread)(define-key notmuch-search-mode-map "R" 'notmuch-search-reply-to-thread-sender);; (setq smtpmail-debug-info t);; (setq smtpmail-debug-verbose t)
getbrew () {which -s brewif [[ $? != 0 ]] ; thenecho "homebrew isn't installed."echo "installing homebrew..."/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"elseecho "updating homebrew"brew updatefi}}install_basics () {echo "sweet, a new machine! installing the basics..."getbrewwhich -s git || brew install gitbrew install vimbrew install tmuxbrew install the_silver_searcher}echo "getting your config files from github"getDotfiles}install_apps () {brew cask install google-chromebrew cask install iterm2brew cask install lastpassbrew cask install spectaclebrew cask install slackbrew cask install atombrew cask install evernotegetDotfiles () {dir=`pwd`mkdir -p ~/dotfilesgit clone https://github.com/mistahchris/dotfiles.git ~/dotfiles# create a symlink for .vimrc and .bash_profile in ~ln -s ~/dotfiles/.bash_profile ~/.bash_profileln -s ~/dotfiles.vimrc ~/.vimrc}install_languages () {brew install pythonbrew install python3brew install gobrew install javabrew install nodebrew install swift