Display command prompt (PS1) info for a set of directories
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
Is there a straightforward way to display the results of my PS1
for a given set of directories?
To avoid the XY Problem, I'll state up front: I want to rapidly check the status of every git repo within a directory. I can run git status
in a for ... do ... done
loop, but that is hard to read.
I have oh-my-git running beautifully as part of my command prompt and it displays the status I'd like to know at a glance. I'd like to see what it says for every sub-directory in my repos
directory.
I can see what I need by manually calling cd ~/repos/first-repo
followed by the next, but besides the repetitive typing, I also have to remember all of the repos without skipping one. I'd be happy to script out cd
ing into each repo and displaying my customized prompt.
bash shell-script git prompt
add a comment |Â
up vote
1
down vote
favorite
Is there a straightforward way to display the results of my PS1
for a given set of directories?
To avoid the XY Problem, I'll state up front: I want to rapidly check the status of every git repo within a directory. I can run git status
in a for ... do ... done
loop, but that is hard to read.
I have oh-my-git running beautifully as part of my command prompt and it displays the status I'd like to know at a glance. I'd like to see what it says for every sub-directory in my repos
directory.
I can see what I need by manually calling cd ~/repos/first-repo
followed by the next, but besides the repetitive typing, I also have to remember all of the repos without skipping one. I'd be happy to script out cd
ing into each repo and displaying my customized prompt.
bash shell-script git prompt
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Is there a straightforward way to display the results of my PS1
for a given set of directories?
To avoid the XY Problem, I'll state up front: I want to rapidly check the status of every git repo within a directory. I can run git status
in a for ... do ... done
loop, but that is hard to read.
I have oh-my-git running beautifully as part of my command prompt and it displays the status I'd like to know at a glance. I'd like to see what it says for every sub-directory in my repos
directory.
I can see what I need by manually calling cd ~/repos/first-repo
followed by the next, but besides the repetitive typing, I also have to remember all of the repos without skipping one. I'd be happy to script out cd
ing into each repo and displaying my customized prompt.
bash shell-script git prompt
Is there a straightforward way to display the results of my PS1
for a given set of directories?
To avoid the XY Problem, I'll state up front: I want to rapidly check the status of every git repo within a directory. I can run git status
in a for ... do ... done
loop, but that is hard to read.
I have oh-my-git running beautifully as part of my command prompt and it displays the status I'd like to know at a glance. I'd like to see what it says for every sub-directory in my repos
directory.
I can see what I need by manually calling cd ~/repos/first-repo
followed by the next, but besides the repetitive typing, I also have to remember all of the repos without skipping one. I'd be happy to script out cd
ing into each repo and displaying my customized prompt.
bash shell-script git prompt
bash shell-script git prompt
asked Sep 25 '17 at 5:39
Dane
190117
190117
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
for rep in */; do
printf '%s:t' "$rep"
( cd "$rep" && git status --short --branch --untracked-files=no )
done
or, using short options,
for rep in */; do
printf '%s:t' "$rep"
( cd "$rep" && git status -sbuno )
done
This changes into each directory in the current directory and runs the given git status
command. The output may look something like
gnomad_browser/: ## master...origin/master
swefreq-browser/: ## gnomad-remerge...origin/gnomad-remerge
swefreq-config/: ## develop...origin/develop
swefreq/: ## feature/schema-update...origin/feature/schema-update
M sql/swefreq.sql
(I have an uncommitted file in the swefreq
repository)
The options picked for git status
here will show just the current branch and any modified files, but you could easily modify it to show untracked files as wull by removing -uno
or --untracked-files=no
.
See git status --help
.
Your idea of using the prompt to show you info about each directory may work depending on how your prompt is set up. My prompt is a single-quoted string that must be evaluated:
for rep in */; do
( cd "$rep" && eval echo "$PS1" )
done
I do not think that this is a very nice solution, and it's also not very flexible in what it can do and tell you about each repository.
eval
is something I wasn't thinking of, and seems to be what I'd like to use, but it chokes on my complexPS1
. It's probably the font-awesome icons included, which is the point.
â Dane
Sep 25 '17 at 12:55
1
I'm glad I included my XY problem clarification because your solution provides 90% of the value I was looking for. I'm changing the string formatting toprintf '%-28s' "$rep"
for myself, but that's pretty nice. Thank you!
â Dane
Sep 25 '17 at 12:58
add a comment |Â
up vote
1
down vote
Looking at oh-my-git, it seems to need you to do something like this in a shell script:
#!/bin/bash
source ~/.oh-my-git/prompt.sh
for d in dir1 dir2...
do cd "$d"
pwd
bash_prompt # recalculate PS1 value
echo -en "$PS1"
done
Here's what I get when I tryecho -en "$PS1"
: imagebin.ca/v/3bddQYqoj7Ik
â Dane
Sep 25 '17 at 19:40
I'm using the usual gnu echo command with option-e
which interpretse
as the escape character. For example,echo -en 'e'|od -c
yields octal code 033. Perhaps you have another echo command earlier in your PATH? If you cannot find a suitable echo you might tryprintf "$PS1"
, as it should interpret thee
when in the format arg, though if you have any%
in the string that would be awkward, and you would needprintf "$PS1//%/%%"
.
â meuh
Sep 26 '17 at 6:49
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
for rep in */; do
printf '%s:t' "$rep"
( cd "$rep" && git status --short --branch --untracked-files=no )
done
or, using short options,
for rep in */; do
printf '%s:t' "$rep"
( cd "$rep" && git status -sbuno )
done
This changes into each directory in the current directory and runs the given git status
command. The output may look something like
gnomad_browser/: ## master...origin/master
swefreq-browser/: ## gnomad-remerge...origin/gnomad-remerge
swefreq-config/: ## develop...origin/develop
swefreq/: ## feature/schema-update...origin/feature/schema-update
M sql/swefreq.sql
(I have an uncommitted file in the swefreq
repository)
The options picked for git status
here will show just the current branch and any modified files, but you could easily modify it to show untracked files as wull by removing -uno
or --untracked-files=no
.
See git status --help
.
Your idea of using the prompt to show you info about each directory may work depending on how your prompt is set up. My prompt is a single-quoted string that must be evaluated:
for rep in */; do
( cd "$rep" && eval echo "$PS1" )
done
I do not think that this is a very nice solution, and it's also not very flexible in what it can do and tell you about each repository.
eval
is something I wasn't thinking of, and seems to be what I'd like to use, but it chokes on my complexPS1
. It's probably the font-awesome icons included, which is the point.
â Dane
Sep 25 '17 at 12:55
1
I'm glad I included my XY problem clarification because your solution provides 90% of the value I was looking for. I'm changing the string formatting toprintf '%-28s' "$rep"
for myself, but that's pretty nice. Thank you!
â Dane
Sep 25 '17 at 12:58
add a comment |Â
up vote
1
down vote
accepted
for rep in */; do
printf '%s:t' "$rep"
( cd "$rep" && git status --short --branch --untracked-files=no )
done
or, using short options,
for rep in */; do
printf '%s:t' "$rep"
( cd "$rep" && git status -sbuno )
done
This changes into each directory in the current directory and runs the given git status
command. The output may look something like
gnomad_browser/: ## master...origin/master
swefreq-browser/: ## gnomad-remerge...origin/gnomad-remerge
swefreq-config/: ## develop...origin/develop
swefreq/: ## feature/schema-update...origin/feature/schema-update
M sql/swefreq.sql
(I have an uncommitted file in the swefreq
repository)
The options picked for git status
here will show just the current branch and any modified files, but you could easily modify it to show untracked files as wull by removing -uno
or --untracked-files=no
.
See git status --help
.
Your idea of using the prompt to show you info about each directory may work depending on how your prompt is set up. My prompt is a single-quoted string that must be evaluated:
for rep in */; do
( cd "$rep" && eval echo "$PS1" )
done
I do not think that this is a very nice solution, and it's also not very flexible in what it can do and tell you about each repository.
eval
is something I wasn't thinking of, and seems to be what I'd like to use, but it chokes on my complexPS1
. It's probably the font-awesome icons included, which is the point.
â Dane
Sep 25 '17 at 12:55
1
I'm glad I included my XY problem clarification because your solution provides 90% of the value I was looking for. I'm changing the string formatting toprintf '%-28s' "$rep"
for myself, but that's pretty nice. Thank you!
â Dane
Sep 25 '17 at 12:58
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
for rep in */; do
printf '%s:t' "$rep"
( cd "$rep" && git status --short --branch --untracked-files=no )
done
or, using short options,
for rep in */; do
printf '%s:t' "$rep"
( cd "$rep" && git status -sbuno )
done
This changes into each directory in the current directory and runs the given git status
command. The output may look something like
gnomad_browser/: ## master...origin/master
swefreq-browser/: ## gnomad-remerge...origin/gnomad-remerge
swefreq-config/: ## develop...origin/develop
swefreq/: ## feature/schema-update...origin/feature/schema-update
M sql/swefreq.sql
(I have an uncommitted file in the swefreq
repository)
The options picked for git status
here will show just the current branch and any modified files, but you could easily modify it to show untracked files as wull by removing -uno
or --untracked-files=no
.
See git status --help
.
Your idea of using the prompt to show you info about each directory may work depending on how your prompt is set up. My prompt is a single-quoted string that must be evaluated:
for rep in */; do
( cd "$rep" && eval echo "$PS1" )
done
I do not think that this is a very nice solution, and it's also not very flexible in what it can do and tell you about each repository.
for rep in */; do
printf '%s:t' "$rep"
( cd "$rep" && git status --short --branch --untracked-files=no )
done
or, using short options,
for rep in */; do
printf '%s:t' "$rep"
( cd "$rep" && git status -sbuno )
done
This changes into each directory in the current directory and runs the given git status
command. The output may look something like
gnomad_browser/: ## master...origin/master
swefreq-browser/: ## gnomad-remerge...origin/gnomad-remerge
swefreq-config/: ## develop...origin/develop
swefreq/: ## feature/schema-update...origin/feature/schema-update
M sql/swefreq.sql
(I have an uncommitted file in the swefreq
repository)
The options picked for git status
here will show just the current branch and any modified files, but you could easily modify it to show untracked files as wull by removing -uno
or --untracked-files=no
.
See git status --help
.
Your idea of using the prompt to show you info about each directory may work depending on how your prompt is set up. My prompt is a single-quoted string that must be evaluated:
for rep in */; do
( cd "$rep" && eval echo "$PS1" )
done
I do not think that this is a very nice solution, and it's also not very flexible in what it can do and tell you about each repository.
edited Sep 25 '17 at 6:15
answered Sep 25 '17 at 6:09
Kusalananda
106k14209327
106k14209327
eval
is something I wasn't thinking of, and seems to be what I'd like to use, but it chokes on my complexPS1
. It's probably the font-awesome icons included, which is the point.
â Dane
Sep 25 '17 at 12:55
1
I'm glad I included my XY problem clarification because your solution provides 90% of the value I was looking for. I'm changing the string formatting toprintf '%-28s' "$rep"
for myself, but that's pretty nice. Thank you!
â Dane
Sep 25 '17 at 12:58
add a comment |Â
eval
is something I wasn't thinking of, and seems to be what I'd like to use, but it chokes on my complexPS1
. It's probably the font-awesome icons included, which is the point.
â Dane
Sep 25 '17 at 12:55
1
I'm glad I included my XY problem clarification because your solution provides 90% of the value I was looking for. I'm changing the string formatting toprintf '%-28s' "$rep"
for myself, but that's pretty nice. Thank you!
â Dane
Sep 25 '17 at 12:58
eval
is something I wasn't thinking of, and seems to be what I'd like to use, but it chokes on my complex PS1
. It's probably the font-awesome icons included, which is the point.â Dane
Sep 25 '17 at 12:55
eval
is something I wasn't thinking of, and seems to be what I'd like to use, but it chokes on my complex PS1
. It's probably the font-awesome icons included, which is the point.â Dane
Sep 25 '17 at 12:55
1
1
I'm glad I included my XY problem clarification because your solution provides 90% of the value I was looking for. I'm changing the string formatting to
printf '%-28s' "$rep"
for myself, but that's pretty nice. Thank you!â Dane
Sep 25 '17 at 12:58
I'm glad I included my XY problem clarification because your solution provides 90% of the value I was looking for. I'm changing the string formatting to
printf '%-28s' "$rep"
for myself, but that's pretty nice. Thank you!â Dane
Sep 25 '17 at 12:58
add a comment |Â
up vote
1
down vote
Looking at oh-my-git, it seems to need you to do something like this in a shell script:
#!/bin/bash
source ~/.oh-my-git/prompt.sh
for d in dir1 dir2...
do cd "$d"
pwd
bash_prompt # recalculate PS1 value
echo -en "$PS1"
done
Here's what I get when I tryecho -en "$PS1"
: imagebin.ca/v/3bddQYqoj7Ik
â Dane
Sep 25 '17 at 19:40
I'm using the usual gnu echo command with option-e
which interpretse
as the escape character. For example,echo -en 'e'|od -c
yields octal code 033. Perhaps you have another echo command earlier in your PATH? If you cannot find a suitable echo you might tryprintf "$PS1"
, as it should interpret thee
when in the format arg, though if you have any%
in the string that would be awkward, and you would needprintf "$PS1//%/%%"
.
â meuh
Sep 26 '17 at 6:49
add a comment |Â
up vote
1
down vote
Looking at oh-my-git, it seems to need you to do something like this in a shell script:
#!/bin/bash
source ~/.oh-my-git/prompt.sh
for d in dir1 dir2...
do cd "$d"
pwd
bash_prompt # recalculate PS1 value
echo -en "$PS1"
done
Here's what I get when I tryecho -en "$PS1"
: imagebin.ca/v/3bddQYqoj7Ik
â Dane
Sep 25 '17 at 19:40
I'm using the usual gnu echo command with option-e
which interpretse
as the escape character. For example,echo -en 'e'|od -c
yields octal code 033. Perhaps you have another echo command earlier in your PATH? If you cannot find a suitable echo you might tryprintf "$PS1"
, as it should interpret thee
when in the format arg, though if you have any%
in the string that would be awkward, and you would needprintf "$PS1//%/%%"
.
â meuh
Sep 26 '17 at 6:49
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Looking at oh-my-git, it seems to need you to do something like this in a shell script:
#!/bin/bash
source ~/.oh-my-git/prompt.sh
for d in dir1 dir2...
do cd "$d"
pwd
bash_prompt # recalculate PS1 value
echo -en "$PS1"
done
Looking at oh-my-git, it seems to need you to do something like this in a shell script:
#!/bin/bash
source ~/.oh-my-git/prompt.sh
for d in dir1 dir2...
do cd "$d"
pwd
bash_prompt # recalculate PS1 value
echo -en "$PS1"
done
answered Sep 25 '17 at 15:51
meuh
29.8k11751
29.8k11751
Here's what I get when I tryecho -en "$PS1"
: imagebin.ca/v/3bddQYqoj7Ik
â Dane
Sep 25 '17 at 19:40
I'm using the usual gnu echo command with option-e
which interpretse
as the escape character. For example,echo -en 'e'|od -c
yields octal code 033. Perhaps you have another echo command earlier in your PATH? If you cannot find a suitable echo you might tryprintf "$PS1"
, as it should interpret thee
when in the format arg, though if you have any%
in the string that would be awkward, and you would needprintf "$PS1//%/%%"
.
â meuh
Sep 26 '17 at 6:49
add a comment |Â
Here's what I get when I tryecho -en "$PS1"
: imagebin.ca/v/3bddQYqoj7Ik
â Dane
Sep 25 '17 at 19:40
I'm using the usual gnu echo command with option-e
which interpretse
as the escape character. For example,echo -en 'e'|od -c
yields octal code 033. Perhaps you have another echo command earlier in your PATH? If you cannot find a suitable echo you might tryprintf "$PS1"
, as it should interpret thee
when in the format arg, though if you have any%
in the string that would be awkward, and you would needprintf "$PS1//%/%%"
.
â meuh
Sep 26 '17 at 6:49
Here's what I get when I try
echo -en "$PS1"
: imagebin.ca/v/3bddQYqoj7Ikâ Dane
Sep 25 '17 at 19:40
Here's what I get when I try
echo -en "$PS1"
: imagebin.ca/v/3bddQYqoj7Ikâ Dane
Sep 25 '17 at 19:40
I'm using the usual gnu echo command with option
-e
which interprets e
as the escape character. For example, echo -en 'e'|od -c
yields octal code 033. Perhaps you have another echo command earlier in your PATH? If you cannot find a suitable echo you might try printf "$PS1"
, as it should interpret the e
when in the format arg, though if you have any %
in the string that would be awkward, and you would need printf "$PS1//%/%%"
.â meuh
Sep 26 '17 at 6:49
I'm using the usual gnu echo command with option
-e
which interprets e
as the escape character. For example, echo -en 'e'|od -c
yields octal code 033. Perhaps you have another echo command earlier in your PATH? If you cannot find a suitable echo you might try printf "$PS1"
, as it should interpret the e
when in the format arg, though if you have any %
in the string that would be awkward, and you would need printf "$PS1//%/%%"
.â meuh
Sep 26 '17 at 6:49
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394240%2fdisplay-command-prompt-ps1-info-for-a-set-of-directories%23new-answer', 'question_page');
);
Post as a guest
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
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
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