sushi/conf.d/ripgrep.fish
2025-05-24 02:58:43 +02:00

39 lines
3.6 KiB
Fish

# Parameters
# You can control ripgrep via the env vars $RG (executable) and $RIPGREP_ARGS (arguments). Then run `update_rg_collection` to apply.
# RG defaulting to rga if not set
if not set -q RG
set -gx RG rga
end
# RIPGREP_ARGS default to '-i' if not set
if not set -q RIPGREP_ARGS
set -gx RIPGREP_ARGS -i
end
function update_rg_collection
# Aliases
alias ripgrep_data_urls="$RG $RIPGREP_ARGS 'data:(.*?)(;base64)?,(.*)'"
alias ripgrep_url="$RG $RIPGREP_ARGS '\\b(?:https?|ftp):\\/\\/[-a-zA-Z0-9+&@#\\/%%?=~_|!:,.;]*[-a-zA-Z0-9+&@#\\/%%=~_|]'"
alias ripgrep_email="$RG $RIPGREP_ARGS '\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b'"
alias ripgrep_ip4="$RG $RIPGREP_ARGS '\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b'"
alias ripgrep_uuid="$RG $RIPGREP_ARGS '\\b[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}\\b'"
alias ripgrep_hex="$RG $RIPGREP_ARGS '0x[0-9a-fA-F]+'"
alias ripgrep_path="$RG $RIPGREP_ARGS '/(?:[^/]+/)*[^/]+'"
alias ripgrep_api_keys="$RG $RIPGREP_ARGS 'access_key|access_token|accessKey|accessToken|api_key|api_secret|apikey|app_id|app_key|app_secret|application_id|asws_secret_token|aws_access|aws_config|aws_key|aws_secret|aws_secret_access_key|aws_secret_key|aws_token|bucket_password|client_secret|connectionstring|consumer_secret|credentials|db_password|db_server|db_username|dbpasswd|dbpassword|dbuser|django_password|email_host_password|facebook_app_secret|facebook_secret|fb_app_secret|fb_secret|google_id|google_oauth|google_oauth_client_id|google_oauth_client_secret|google_oauth_secret|google_secret|google_server_key|gsecr|heroku_api_key|heroku_key|heroku_oauth|heroku_oauth_secret|heroku_oauth_token|heroku_secret|heroku_secret_token|jwt_secret|jwt_token|jwt_secret_token|keyPassword|mailgun_key|mailgun_secret|mysql_password|oauth_key|oauth_token|oauth2_secret|password|paypal_identity_token|paypal_sandbox|paypal_secret|paypal_token|postgres_password|private|private_key|redis_password|root_password|sa_password|secret|secret_access_key|secret_bearer|secret_key|secret_token|secretKey|security_credentials|send_keys|sf_username|slack_channel|slack_key|slack_secret|slack_token|slack_url|slack_webhook|slack_webhook_url|square_access_token|square_apikey|square_app|square_app_id|square_appid|square_secret|square_token|squareSecret|squareToken|ssh2_auth_password|sshkey|storePassword|strip_key|strip_secret|strip_secret_token|strip_token|stripe_key|stripe_secret|stripe_secret_token|stripe_token|stripSecret|stripToken|twitter_api_secret|twitter_consumer_key|twitter_consumer_secret|twitter_key|twitter_secret|twitter_token|twitterKey|twitterSecret|wordpress_password'"
alias ripgrep_aws_keys="$RG $RIPGREP_ARGS '([^A-Z0-9]|^)(AKIA|A3T|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{12,}'"
alias ripgrep_s3_buckets="$RG $RIPGREP_ARGS '[a-z0-9.-]+\\.s3\\.amazonaws\\.com|[a-z0-9.-]+\\.s3-[a-z0-9-]\\.amazonaws\\.com|[a-z0-9.-]+\\.s3-website[.-](eu|ap|us|ca|sa|cn)|//s3\\.amazonaws\\.com/[a-z0-9._-]+|//s3-[a-z0-9-]+\\.amazonaws\\.com/[a-z0-9._-]+'"
alias ripgrep_sec="$RG $RIPGREP_ARGS '(aws_access|aws_secret|api[_-]?key|ListBucketResult|S3_ACCESS_KEY|Authorization:|RSA PRIVATE|Index of|aws_|secret|ssh-rsa AA)'"
alias ripgrep_copyright="$RG $RIPGREP_ARGS '(copyright|\\u0026copy;|\\\\(c\\\\)|©) *[12][0-9]{3}'"
alias ripgrep_todo="$RG $RIPGREP_ARGS 'todo|unimplemented|refactor|wip'"
alias ripgrep_review="$RG $RIPGREP_ARGS 'review|deprecated'"
alias ripgrep_fix="$RG $RIPGREP_ARGS 'fix|fixme'"
alias ripgrep_rocket_routes="$RG $RIPGREP_ARGS '#\\\\[(\\\\w+)\\\\(\"[^\"]*\"'"
set code_words '`([^`]+)`'
alias ripgrep_code_words="$RG $RIPGREP_ARGS $code_words"
end
update_rg_collection