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?
command-line tree
add a comment |
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?
command-line tree
add a comment |
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?
command-line tree
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
command-line tree
asked Nov 25 at 16:15
Michał Rowicki
1083
1083
add a comment |
add a comment |
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:
It's really cool, thank you for your hard work! 💪
– Michał Rowicki
Nov 26 at 6:13
add a comment |
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:
It's really cool, thank you for your hard work! 💪
– Michał Rowicki
Nov 26 at 6:13
add a comment |
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:
It's really cool, thank you for your hard work! 💪
– Michał Rowicki
Nov 26 at 6:13
add a comment |
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:
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:
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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