Show tree of directory with files content











up vote
1
down vote

favorite












I would like to print out in terminal tree like one below:




$ tree -a
.
└── .git
├── branches
├── config
├── description
├── HEAD
├── hooks
│   ├── applypatch-msg.sample
│   ├── commit-msg.sample
│   ├── fsmonitor-watchman.sample
│   ├── post-update.sample
│   ├── pre-applypatch.sample
│   ├── pre-commit.sample
│   ├── prepare-commit-msg.sample
│   ├── pre-push.sample
│   ├── pre-rebase.sample
│   ├── pre-receive.sample
│   └── update.sample
├── info
│   └── exclude
├── objects
│   ├── info
│   └── pack
└── refs
├── heads
└── tags



With graphically presented content of all files ie it should like respectively?




.
└── .git
├── branches
├── config
|
| [core]
| repositoryformatversion = 0
| filemode = true
| bare = false
| logallrefupdates = true
|
├── description
|
| Unnamed repository; edit this file 'description' to name the repository.
|
├── HEAD
|
| ref: refs/heads/master
|


Is there an easy way to reach that?










share|improve this question


























    up vote
    1
    down vote

    favorite












    I would like to print out in terminal tree like one below:




    $ tree -a
    .
    └── .git
    ├── branches
    ├── config
    ├── description
    ├── HEAD
    ├── hooks
    │   ├── applypatch-msg.sample
    │   ├── commit-msg.sample
    │   ├── fsmonitor-watchman.sample
    │   ├── post-update.sample
    │   ├── pre-applypatch.sample
    │   ├── pre-commit.sample
    │   ├── prepare-commit-msg.sample
    │   ├── pre-push.sample
    │   ├── pre-rebase.sample
    │   ├── pre-receive.sample
    │   └── update.sample
    ├── info
    │   └── exclude
    ├── objects
    │   ├── info
    │   └── pack
    └── refs
    ├── heads
    └── tags



    With graphically presented content of all files ie it should like respectively?




    .
    └── .git
    ├── branches
    ├── config
    |
    | [core]
    | repositoryformatversion = 0
    | filemode = true
    | bare = false
    | logallrefupdates = true
    |
    ├── description
    |
    | Unnamed repository; edit this file 'description' to name the repository.
    |
    ├── HEAD
    |
    | ref: refs/heads/master
    |


    Is there an easy way to reach that?










    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I would like to print out in terminal tree like one below:




      $ tree -a
      .
      └── .git
      ├── branches
      ├── config
      ├── description
      ├── HEAD
      ├── hooks
      │   ├── applypatch-msg.sample
      │   ├── commit-msg.sample
      │   ├── fsmonitor-watchman.sample
      │   ├── post-update.sample
      │   ├── pre-applypatch.sample
      │   ├── pre-commit.sample
      │   ├── prepare-commit-msg.sample
      │   ├── pre-push.sample
      │   ├── pre-rebase.sample
      │   ├── pre-receive.sample
      │   └── update.sample
      ├── info
      │   └── exclude
      ├── objects
      │   ├── info
      │   └── pack
      └── refs
      ├── heads
      └── tags



      With graphically presented content of all files ie it should like respectively?




      .
      └── .git
      ├── branches
      ├── config
      |
      | [core]
      | repositoryformatversion = 0
      | filemode = true
      | bare = false
      | logallrefupdates = true
      |
      ├── description
      |
      | Unnamed repository; edit this file 'description' to name the repository.
      |
      ├── HEAD
      |
      | ref: refs/heads/master
      |


      Is there an easy way to reach that?










      share|improve this question













      I would like to print out in terminal tree like one below:




      $ tree -a
      .
      └── .git
      ├── branches
      ├── config
      ├── description
      ├── HEAD
      ├── hooks
      │   ├── applypatch-msg.sample
      │   ├── commit-msg.sample
      │   ├── fsmonitor-watchman.sample
      │   ├── post-update.sample
      │   ├── pre-applypatch.sample
      │   ├── pre-commit.sample
      │   ├── prepare-commit-msg.sample
      │   ├── pre-push.sample
      │   ├── pre-rebase.sample
      │   ├── pre-receive.sample
      │   └── update.sample
      ├── info
      │   └── exclude
      ├── objects
      │   ├── info
      │   └── pack
      └── refs
      ├── heads
      └── tags



      With graphically presented content of all files ie it should like respectively?




      .
      └── .git
      ├── branches
      ├── config
      |
      | [core]
      | repositoryformatversion = 0
      | filemode = true
      | bare = false
      | logallrefupdates = true
      |
      ├── description
      |
      | Unnamed repository; edit this file 'description' to name the repository.
      |
      ├── HEAD
      |
      | ref: refs/heads/master
      |


      Is there an easy way to reach that?







      command-line tree






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 25 at 16:15









      Michał Rowicki

      1083




      1083






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          I'm not aware of an easy way to do that, but I wrote a script that does something similar. Instead of a fancy tree listing like tree does, I made it flat, like find.



          Output (in an empty git repo like your example):



          .git/
          .git/branches/
          .git/config
          ==> start .git/config <==
          [core]
          repositoryformatversion = 0
          filemode = true
          bare = false
          logallrefupdates = true
          ==> end .git/config <==

          .git/description
          ==> start .git/description <==
          Unnamed repository; edit this file 'description' to name the repository.
          ==> end .git/description <==

          .git/HEAD
          ==> start .git/HEAD <==
          ref: refs/heads/master
          ==> end .git/HEAD <==

          .git/hooks/

          ...


          (The ==> ... <== header/footer is inspired by tail)



          Here's the script:



          #!/bin/bash

          # Globs include hidden files, are null if no matches, recursive with **
          shopt -s dotglob nullglob globstar

          for file in **; do
          # Print filename with an indicator suffix for filetype
          ls --directory --classify -- "$file"
          filetype="$(file --brief --mime-type -- "$file")"
          # Only print text files
          if [[ $filetype == text/* ]]; then
          printf '==> %s %s <==n' start "$file"
          cat --show-nonprinting -- "$file"
          printf '==> %s %s <==n' end "$file"
          echo
          fi
          done


          It's not pretty, but it works. Color makes it pretty at least:



          #!/bin/bash

          shopt -s dotglob nullglob globstar

          for file in **; do
          ls --directory --classify --color=yes -- "$file"
          filetype="$(file --brief --mime-type -- "$file")"
          # Only print text files
          if [[ $filetype == text/* ]]; then
          printf 'e[32m==> %s %s <==e[mn' start "$file"
          cat --show-nonprinting -- "$file"
          printf 'e[31m==> %s %s <==e[mn' end "$file"
          echo
          fi
          done


          Screenshot:



          Screenshot showing filename colorized by <code>ls</code>, "start" marker in green, and "end" marker in red






          share|improve this answer























          • It's really cool, thank you for your hard work! 💪
            – Michał Rowicki
            Nov 26 at 6:13











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1095947%2fshow-tree-of-directory-with-files-content%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote



          accepted










          I'm not aware of an easy way to do that, but I wrote a script that does something similar. Instead of a fancy tree listing like tree does, I made it flat, like find.



          Output (in an empty git repo like your example):



          .git/
          .git/branches/
          .git/config
          ==> start .git/config <==
          [core]
          repositoryformatversion = 0
          filemode = true
          bare = false
          logallrefupdates = true
          ==> end .git/config <==

          .git/description
          ==> start .git/description <==
          Unnamed repository; edit this file 'description' to name the repository.
          ==> end .git/description <==

          .git/HEAD
          ==> start .git/HEAD <==
          ref: refs/heads/master
          ==> end .git/HEAD <==

          .git/hooks/

          ...


          (The ==> ... <== header/footer is inspired by tail)



          Here's the script:



          #!/bin/bash

          # Globs include hidden files, are null if no matches, recursive with **
          shopt -s dotglob nullglob globstar

          for file in **; do
          # Print filename with an indicator suffix for filetype
          ls --directory --classify -- "$file"
          filetype="$(file --brief --mime-type -- "$file")"
          # Only print text files
          if [[ $filetype == text/* ]]; then
          printf '==> %s %s <==n' start "$file"
          cat --show-nonprinting -- "$file"
          printf '==> %s %s <==n' end "$file"
          echo
          fi
          done


          It's not pretty, but it works. Color makes it pretty at least:



          #!/bin/bash

          shopt -s dotglob nullglob globstar

          for file in **; do
          ls --directory --classify --color=yes -- "$file"
          filetype="$(file --brief --mime-type -- "$file")"
          # Only print text files
          if [[ $filetype == text/* ]]; then
          printf 'e[32m==> %s %s <==e[mn' start "$file"
          cat --show-nonprinting -- "$file"
          printf 'e[31m==> %s %s <==e[mn' end "$file"
          echo
          fi
          done


          Screenshot:



          Screenshot showing filename colorized by <code>ls</code>, "start" marker in green, and "end" marker in red






          share|improve this answer























          • It's really cool, thank you for your hard work! 💪
            – Michał Rowicki
            Nov 26 at 6:13















          up vote
          2
          down vote



          accepted










          I'm not aware of an easy way to do that, but I wrote a script that does something similar. Instead of a fancy tree listing like tree does, I made it flat, like find.



          Output (in an empty git repo like your example):



          .git/
          .git/branches/
          .git/config
          ==> start .git/config <==
          [core]
          repositoryformatversion = 0
          filemode = true
          bare = false
          logallrefupdates = true
          ==> end .git/config <==

          .git/description
          ==> start .git/description <==
          Unnamed repository; edit this file 'description' to name the repository.
          ==> end .git/description <==

          .git/HEAD
          ==> start .git/HEAD <==
          ref: refs/heads/master
          ==> end .git/HEAD <==

          .git/hooks/

          ...


          (The ==> ... <== header/footer is inspired by tail)



          Here's the script:



          #!/bin/bash

          # Globs include hidden files, are null if no matches, recursive with **
          shopt -s dotglob nullglob globstar

          for file in **; do
          # Print filename with an indicator suffix for filetype
          ls --directory --classify -- "$file"
          filetype="$(file --brief --mime-type -- "$file")"
          # Only print text files
          if [[ $filetype == text/* ]]; then
          printf '==> %s %s <==n' start "$file"
          cat --show-nonprinting -- "$file"
          printf '==> %s %s <==n' end "$file"
          echo
          fi
          done


          It's not pretty, but it works. Color makes it pretty at least:



          #!/bin/bash

          shopt -s dotglob nullglob globstar

          for file in **; do
          ls --directory --classify --color=yes -- "$file"
          filetype="$(file --brief --mime-type -- "$file")"
          # Only print text files
          if [[ $filetype == text/* ]]; then
          printf 'e[32m==> %s %s <==e[mn' start "$file"
          cat --show-nonprinting -- "$file"
          printf 'e[31m==> %s %s <==e[mn' end "$file"
          echo
          fi
          done


          Screenshot:



          Screenshot showing filename colorized by <code>ls</code>, "start" marker in green, and "end" marker in red






          share|improve this answer























          • It's really cool, thank you for your hard work! 💪
            – Michał Rowicki
            Nov 26 at 6:13













          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          I'm not aware of an easy way to do that, but I wrote a script that does something similar. Instead of a fancy tree listing like tree does, I made it flat, like find.



          Output (in an empty git repo like your example):



          .git/
          .git/branches/
          .git/config
          ==> start .git/config <==
          [core]
          repositoryformatversion = 0
          filemode = true
          bare = false
          logallrefupdates = true
          ==> end .git/config <==

          .git/description
          ==> start .git/description <==
          Unnamed repository; edit this file 'description' to name the repository.
          ==> end .git/description <==

          .git/HEAD
          ==> start .git/HEAD <==
          ref: refs/heads/master
          ==> end .git/HEAD <==

          .git/hooks/

          ...


          (The ==> ... <== header/footer is inspired by tail)



          Here's the script:



          #!/bin/bash

          # Globs include hidden files, are null if no matches, recursive with **
          shopt -s dotglob nullglob globstar

          for file in **; do
          # Print filename with an indicator suffix for filetype
          ls --directory --classify -- "$file"
          filetype="$(file --brief --mime-type -- "$file")"
          # Only print text files
          if [[ $filetype == text/* ]]; then
          printf '==> %s %s <==n' start "$file"
          cat --show-nonprinting -- "$file"
          printf '==> %s %s <==n' end "$file"
          echo
          fi
          done


          It's not pretty, but it works. Color makes it pretty at least:



          #!/bin/bash

          shopt -s dotglob nullglob globstar

          for file in **; do
          ls --directory --classify --color=yes -- "$file"
          filetype="$(file --brief --mime-type -- "$file")"
          # Only print text files
          if [[ $filetype == text/* ]]; then
          printf 'e[32m==> %s %s <==e[mn' start "$file"
          cat --show-nonprinting -- "$file"
          printf 'e[31m==> %s %s <==e[mn' end "$file"
          echo
          fi
          done


          Screenshot:



          Screenshot showing filename colorized by <code>ls</code>, "start" marker in green, and "end" marker in red






          share|improve this answer














          I'm not aware of an easy way to do that, but I wrote a script that does something similar. Instead of a fancy tree listing like tree does, I made it flat, like find.



          Output (in an empty git repo like your example):



          .git/
          .git/branches/
          .git/config
          ==> start .git/config <==
          [core]
          repositoryformatversion = 0
          filemode = true
          bare = false
          logallrefupdates = true
          ==> end .git/config <==

          .git/description
          ==> start .git/description <==
          Unnamed repository; edit this file 'description' to name the repository.
          ==> end .git/description <==

          .git/HEAD
          ==> start .git/HEAD <==
          ref: refs/heads/master
          ==> end .git/HEAD <==

          .git/hooks/

          ...


          (The ==> ... <== header/footer is inspired by tail)



          Here's the script:



          #!/bin/bash

          # Globs include hidden files, are null if no matches, recursive with **
          shopt -s dotglob nullglob globstar

          for file in **; do
          # Print filename with an indicator suffix for filetype
          ls --directory --classify -- "$file"
          filetype="$(file --brief --mime-type -- "$file")"
          # Only print text files
          if [[ $filetype == text/* ]]; then
          printf '==> %s %s <==n' start "$file"
          cat --show-nonprinting -- "$file"
          printf '==> %s %s <==n' end "$file"
          echo
          fi
          done


          It's not pretty, but it works. Color makes it pretty at least:



          #!/bin/bash

          shopt -s dotglob nullglob globstar

          for file in **; do
          ls --directory --classify --color=yes -- "$file"
          filetype="$(file --brief --mime-type -- "$file")"
          # Only print text files
          if [[ $filetype == text/* ]]; then
          printf 'e[32m==> %s %s <==e[mn' start "$file"
          cat --show-nonprinting -- "$file"
          printf 'e[31m==> %s %s <==e[mn' end "$file"
          echo
          fi
          done


          Screenshot:



          Screenshot showing filename colorized by <code>ls</code>, "start" marker in green, and "end" marker in red







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 26 at 3:44

























          answered Nov 26 at 3:30









          wjandrea

          7,96242258




          7,96242258












          • It's really cool, thank you for your hard work! 💪
            – Michał Rowicki
            Nov 26 at 6:13


















          • It's really cool, thank you for your hard work! 💪
            – Michał Rowicki
            Nov 26 at 6:13
















          It's really cool, thank you for your hard work! 💪
          – Michał Rowicki
          Nov 26 at 6:13




          It's really cool, thank you for your hard work! 💪
          – Michał Rowicki
          Nov 26 at 6:13


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1095947%2fshow-tree-of-directory-with-files-content%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How did Captain America manage to do this?

          迪纳利

          南乌拉尔铁路局