{"id":743,"date":"2025-06-14T05:41:55","date_gmt":"2025-06-14T05:41:55","guid":{"rendered":"https:\/\/datadandies.nl\/?p=743"},"modified":"2025-06-14T05:41:55","modified_gmt":"2025-06-14T05:41:55","slug":"create-a-directory-tree-of-your-repository-in-text-format-to-feed-to-ai","status":"publish","type":"post","link":"https:\/\/datadandies.nl\/index.php\/2025\/06\/14\/create-a-directory-tree-of-your-repository-in-text-format-to-feed-to-ai\/","title":{"rendered":"Create a directory tree of your repository in text format to feed to AI"},"content":{"rendered":"\n<p>Ever wanted to feed the directory tree of your repository to AI?<\/p>\n\n\n\n<p>In order for AI to help you, you need to give it the right context.<\/p>\n\n\n\n<p>Sometimes, this means giving it the directory tree of your repo. You could use the standard \u201ctree\u201d command by installing it using \u201csudo apt install tree\u201d in Linux. But, you could also create a function yourself!<\/p>\n\n\n\n<p>Below is a bash function that you can use to generate a directory tree in text format. First you define the function (which can be done in the terminal) and later you execute it by going to the directory you wish to share and simply typing \u201ctree\u201d in the terminal.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1.3rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * 1.3rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">Bash<\/span><\/span><span role=\"button\" tabindex=\"0\" data-code=\"function tree() {\n\n\u00a0\u00a0\u00a0 find ${1:-.} | sed -e &quot;s\/[^-][^\\\/]*\\\/\/ |\/g&quot; -e &quot;s\/|\\([^ ]\\)\/|-\\1\/&quot;\n\n}\" style=\"color:#D4D4D4;display:none\" aria-label=\"Kopieer\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">function<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">tree<\/span><span style=\"color: #D4D4D4\">() {<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #DCDCAA\">\u00a0\u00a0\u00a0<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">find<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">${1<\/span><span style=\"color: #D4D4D4\">:-.<\/span><span style=\"color: #9CDCFE\">}<\/span><span style=\"color: #D4D4D4\"> | <\/span><span style=\"color: #DCDCAA\">sed<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">-e<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;s\/[^-][^\\\/]*\\\/\/ |\/g&quot;<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">-e<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;s\/|\\([^ ]\\)\/|-\\1\/&quot;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span><\/code><\/pre><span style=\"display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#1E1E1E;color:#c7c7c7;font-size:12px;line-height:1;position:relative\">Bash<\/span><\/div>\n\n\n\n<p>The directory tree in text format will look like below:<\/p>\n\n\n\n<p>|-.gitignore<\/p>\n\n\n\n<p>|-Dockerfile<\/p>\n\n\n\n<p>|-MAINTAINERS.md<\/p>\n\n\n\n<p>|-package-lock.json<\/p>\n\n\n\n<p>|-package.json<\/p>\n\n\n\n<p>|-public<\/p>\n\n\n\n<p>| |-favicon.ico<\/p>\n\n\n\n<p>| |-index.html<\/p>\n\n\n\n<p>| |-robots.txt<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"636\" height=\"464\" src=\"https:\/\/datadandies.nl\/wp-content\/uploads\/2025\/06\/20250614-Bash-functie-voor-directory-tree.png\" alt=\"\" class=\"wp-image-744\" srcset=\"https:\/\/datadandies.nl\/wp-content\/uploads\/2025\/06\/20250614-Bash-functie-voor-directory-tree.png 636w, https:\/\/datadandies.nl\/wp-content\/uploads\/2025\/06\/20250614-Bash-functie-voor-directory-tree-300x219.png 300w\" sizes=\"auto, (max-width: 636px) 100vw, 636px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Ever wanted to feed the directory tree of your repository to AI? In order for AI to help you, you need to give it the right context. Sometimes, this means giving it the directory tree of your repo. You could use the standard \u201ctree\u201d command by installing it using \u201csudo apt install tree\u201d in Linux.&hellip;<\/p>\n<p class=\"more-link\"><a href=\"https:\/\/datadandies.nl\/index.php\/2025\/06\/14\/create-a-directory-tree-of-your-repository-in-text-format-to-feed-to-ai\/\" class=\"themebutton\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[65,74],"class_list":["post-743","post","type-post","status-publish","format-standard","hentry","category-blog","tag-ai","tag-bash"],"_links":{"self":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts\/743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/comments?post=743"}],"version-history":[{"count":1,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts\/743\/revisions"}],"predecessor-version":[{"id":745,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts\/743\/revisions\/745"}],"wp:attachment":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/media?parent=743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/categories?post=743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/tags?post=743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}