CLI off-topic

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
1,098
Reaction score
941
Credits
8,478
In another topic @osprey said this:

Maybe the following works. It works with bash on debian here as shown on the command line. For persistence the PS1 code can be placed in .bashrc.
Code:
[ben@computer ~]$ PS1="[rado@resist] $"
[rado@resist] $

I decided to open a new topic, bc that other topic became a pool of off-topic. Whereas here in the CLI off-topic, we can discuss anything without clogging other topics.

Osprey's method (thanks for the idea, btw!) lacks something and PS1 simply takes the color of the regular text. So I asked an AI how to make it like the original. The AI gave me this code for ~/.bashrc (I put this at the very end of the file) which uses the user-defined colors in the terminal, so now it's practically indistinguishable from the original and nobody knows that the hostname is still "arch". :)

Code:
# Custom resist prompt in terminal, using the colors set by the user in the terminal config
PS1="$(tput setaf 2)[rado@$(tput setaf 7)resist$(tput setaf 2)]$(tput setaf 15): $(tput setaf 7)\w$(tput setaf 2)>\$$(tput sgr0) "

Picture_created_15-06-2026_00-28-44.png


terminal-colors.png
 


Isn't it better to discuss that in your ResistOS topic as you asked the question there, where @osprey replied to you?
 
Isn't it better to discuss that in your ResistOS topic as you asked the question there, where @osprey replied to you?
The idea of this topic is to discuss anything CLI related that doesn't fit in any other topic. I think this matter falls under this term. This here is related to all CLI, not just mine, that's why it's here.
But if you think it's not OK to have an off-topic, delete it.

I discovered a bug with this method of replacing PS1, so I had to revert back to the original and I'll have to look for other ways. So if you delete this topic, it won't be a loss.
 
I am inclined to agree with Maarten.

Moving this to Off Topic is not a solution, because it will inevitably draw Support questions, and responses in Off Topic do not generate a display in New Posts.

That being said, I am interested in what the OP is seeking to achieve with this method, and would be interested in seeing how his efforts pan out.

I'll sleep on it.

Wiz
 
For now I can say I think I fixed the bug with PS1 which was causing the cursor to jump back and forward. It turned out a few lines up (out of the screen) there was another default PS1 description which caused a conflict with mine. So I commented the default one, instead of deleting it - just in case) and the prompt is now what I wanted it to be - without the need to change the hostname.

On another matter: how do you, guys, feel about a little script challenge to scratch your heads? I know the answer bc I wrote that script. The question is not what the script does (creates a backup of all of my scripts, if it matters), but WHY it has password with encryption on it? No, it's not security to hide data, it's something else much simpler.
So far I asked all the AIs I could think of but none of them was able to guess "the why". You could consider this challenge a test of how well you know linux. :P

Code:
#!/usr/bin/env bash

aliasdir=/B/ALIASES
aliasbackup=/BACKUP/LINUX/ALIASES
archname="CLI-SCRIPTS-AND-ALIASES.7z"
options9="-mx9 -mmt20 -md=460m"
password="-p@@1234@@ -mhe"
scripts="/B/CLI/SCRIPTS"
hidden_files=(
    ~/.aliases-txt
    ~/.bashrc
    ~/.bash_profile
    ~/.inputrc
    ~/.XSession
    ~/.XCompose
)

$aliasbackup/$archname &&
7z a $aliasdir/$archname "${hidden_files[@]}" $scripts $password $options9 &&
cp -v $aliasdir/$archname $aliasbackup &&
cp -v $aliasdir/$archname /B/123
 


Follow Linux.org


Top