Starship: Provide the option of formatting user, host, and path as `user@host:path`

Created on 10 Dec 2019  ·  4Comments  ·  Source: starship/starship

While the current <user> on <host> in <directory> formatting works perfectly well and is easy to read, it would be nice to have the option of displaying those values as <user>@<host>:<directory>.

In particular, this would facilitate easy (read: lazy) formulation of scp, rsync, and git commands. If I have two terminal sessions open, one local to my machine and the other an SSH session to remote host, and I want to rsync something from my local machine to my current directory on the remote host, all I have to type is the beginning of the command: rsync <local_file>.

Then I copy the <user>@<host>:<directory> string from the session on the remote host,
paste it into the local session, hit return, and I'm off to the races.

This would of course require the display of full host name and path to be useful, but I already have those enabled.

(This request might, of course, be rendered moot by the ongoing effort to generalize the formatting of module output.)

✨ enhancement

Most helpful comment

From the docs I expected these to be a combination of prefix/suffix. So,

[directory]                                                                     
truncation_length = 0                                                           
truncate_to_repo = false                                                        
prefix = ":"                                                                    

[username]                                                                      
show_always = true                                                              
suffix = ""                                                                     

[hostname]                                                                      
prefix = "@"                                                                    
suffix = ""                                                                     

resulted in

<username> on @<hostname> :<directory>
❯ 

Seems, the prefix of directory was the only one that work as expected.

All 4 comments

From the docs I expected these to be a combination of prefix/suffix. So,

[directory]                                                                     
truncation_length = 0                                                           
truncate_to_repo = false                                                        
prefix = ":"                                                                    

[username]                                                                      
show_always = true                                                              
suffix = ""                                                                     

[hostname]                                                                      
prefix = "@"                                                                    
suffix = ""                                                                     

resulted in

<username> on @<hostname> :<directory>
❯ 

Seems, the prefix of directory was the only one that work as expected.

FYI: #1102 for hostname formatting may be related.

With the new format config, this is possible:

[username]
format = "[$user]($style)"

[hostname]
format = "@[$hostname]($style):"

[directory]
truncation_length = 8
truncate_to_repo = false

displays as

js@littlebottom2:~/external
[17:31:36] λ

Since we are getting close to the v0.45.0 release, I'm going to close this issue so we can see what is actually left to do in the milestone and what still needs a little bit of work.

Was this page helpful?
0 / 5 - 0 ratings