0

Just a quick one.

Trying to modify my PS1 to show just a specific number of chracters.

Currently :

[email protected]@linuxhostname

This is because I have just intergrated some systems in my environment which allow a windows user to log into a linux environment using windows ceredntials. Hense the double domain.

I want to remove everything after the first @ symbol, which currently fits in the \u switch.

Is there a way to tell the \u switch to only use say the first 4 characters of the user-name. So instead of "[email protected]", I get just "user", ultimalty getting user@linuxhost?

Thanks in advance!!!

2 Answers 2

0

I tested this on my Mint 19.2 system, and it should give you want you want. Replace the \u in your .bashrc with ${LOGNAME:0:4}, then resource it.

3
  • Thanks. I will give this a go and let you know. Commented Sep 12, 2019 at 18:49
  • ${LOGNAME:0:4} does match the OP's request for "the first 4 characters of the user-name", but ${LOGNAME%%@*} would make more sense in general. Commented Sep 12, 2019 at 18:52
  • Ok so I took your example and researched a little more. Replacing \u with ${USER::-13} This removed the last 13 characters from the end of the username and returned user@linuxhostname as required. Thanks for the input. Commented Sep 14, 2019 at 12:37
0

Replacing \u with ${USER::-13} This removed the last 13 characters from the end of the username and returned user@linuxhostname as required.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .