-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
103 additions
and
382 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env python3 | ||
|
||
"""This script extract the code blocks from the string passed as standard input.""" | ||
|
||
import re | ||
import sys | ||
|
||
if __name__ == '__main__': | ||
content = sys.stdin.read() | ||
#code_blocks = [] | ||
|
||
code_blocks = re.findall(r"(?:```\S+\\n)(.*)(?:\\n```)", content, re.DOTALL) | ||
|
||
print("\n\n".join(code_blocks)) | ||
|
||
sys.exit(0) | ||
# split = re.split(r"```\S+\s", content, maxsplit=1) | ||
|
||
# while len(split) > 1: | ||
# double_split = re.split(r"```\s", split[1], maxsplit=1) | ||
# code_blocks.append(double_split[0]) | ||
# content = double_split[1] | ||
# split = re.split(r"```\S+\s", content, maxsplit=1) | ||
|
||
# code_blocks.append(split[0]) | ||
# print('\n\n'.join(code_blocks)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env zsh | ||
|
||
sed -n '/^```/,/^```$/p' "$1" | sed '1d;$d' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/zsh | ||
|
||
# The script begins by defining a check for the presence of the `fzf_browse_jsonl` function. | ||
# If the function is not found in the global functions list, the script throws an error and exits. | ||
|
||
# fzf_browse_with_search_jsonl will operate on top of the fzf_browse_jsonl function by creating a custom FZF command with the ctrl+s keybinding enabled for searching. | ||
|
||
: <<'END' | ||
fzf_browse_with_search_jsonl utilizes fzf_browse_jsonl, which provides pretty printed representation of json data from jsonl files in a preview window, | ||
to enable searching within values in the json data with the ctrl+s keybinding. | ||
END | ||
fzf_browse_with_search_jsonl() { | ||
# 'export' function is used to export the defined 'FZF_DEFAULT_COMMAND' to child processes. | ||
# Keybinding 'ctrl+s' is enabled with the '--bind' flag. | ||
export FZF_DEFAULT_COMMAND='fzf_browse_jsonl' | ||
fzf --bind "ctrl+s:toggle-search" | ||
} | ||
|
||
# Call the searching function. | ||
fzf_browse_with_search_jsonl |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env zsh | ||
# This script takes a single quoted string as input with newline (\n) and double quote (\") characters escaped. | ||
# It unescapes these characters and pretty-prints the resulting string. | ||
|
||
# Check for the correct number of arguments. If not exactly one, print an error message and exit. | ||
if [ "$#" -ne 1 ]; then | ||
echo "Usage: $0 \"<string_with_escaped_characters>\"" | ||
exit 1 | ||
fi | ||
|
||
# Replace escaped newline and double quote characters with their unescaped versions. | ||
# Note: `echo` is used here with the `-e` option to enable interpretation of backslash escapes. | ||
echo -e $1 # | sed '//\n/g' | sed '/\//g' | ||
|
||
|
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.