Turn off terminal entry line prefix/header - linux

How do I fix this? I don't want to change my server name I just want to customize the text here (no server name, still shows path/user). Also what's this section of the terminal window called?

The Terminal Entry line prefix is called the shell prompt.
You can generally find the current config by typing
echo $PS1
That returned this for me: [\e]0;\u#^C\w\a]${debian_chroot:+($debian_chroot)}\u#\h:\w\$
So I was able to remove the "#\h" in both locations and get the desired tag.
export PS1="\[\e]0;\u: \w\a\]${debian_chroot:+($debian_chroot)}\u:\w\$ "
leaving me with "root:/kliq$'

Related

Linux modify cshrc file for path above prompt

I would like some help to set up my .cshrc to display my current path above my prompt every time I a new prompt displays.
Terminal Example:
/current/directory/path
username#machinename > enter cmd prompt
/current/directory/path
username#machinename > display whatever return
Thanks in advance!
If you are using tcsh, the following should work:
set prompt = "%~\n%n#%m > "
Brief explanation:
%~ shows the current directory, using "~" for home;
\n moves to the next line;
%n is the user name;
%m is the host name up to the first dot.
For more information, refer to the manual page for tcsh(1), section "Special shell variables".

Hide username and computer name from Git Bash for Windows 10

Is there any way to remove the username and computer name from Git Bash for Window 10?
I already checked this : https://github.com/Maximus5/ConEmu/issues/199
But didn't understand how to do that.
Follow the steps below:
Go to C:\Program Files\Git\etc\profile.d\ folder
Find and open the git-prompt.sh file in your favorite text editor
Go to line number 15
Replace the whole line with PS1="$PS1"''
That's it. Start/Restart Git Bash and you should see the username and computer name is gone.
NOTE: You can also hide the annoying MINGW64 text by commenting out the line number 16 and 17 of the same file. To comment out those lines just add a # to the beginning of the line. That's it. Now start/restart Git Bash and it should go away.
Better way!!
Follow the steps as mentioned by #Saabbir, with one big change:
# 👇 comment out the wrapping if-else block
if test -f ~/.config/git/git-prompt.sh
then
. ~/.config/git/git-prompt.sh
else
# 👇 leave the content uncommented
...
fi
Save the file, git-prompt.sh using Save As (in your editor) in this path C:\Users\{current_windows_user}\.config\git
Explanation: You can see on line number 8 that it checks for the same file on ~/.config/git. So it's better to update the config file rather than the actual settings file.

What does this PROMPT_COMMAND do?

I have this in /etc/bash.bashrc on my Linux system:
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s#%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
From man bash I understand that it sets a command to be executed prior to issuing each prompt, but I'm wondering what exactly it's doing.
Basically, it updates the title of the terminal after every command you issue to reflect the current values of the envariables, using XTerm escape sequences.
Some of the escape sequences recognized by XTerm-compatible terminal emulators:
ESC]0;stringBEL — Set icon name and window title to string
ESC]1;stringBEL — Set icon name to string
ESC]2;stringBEL — Set window title to string
where ESC is the escape character (\033), and BEL is the bell character (\007).
Sets your prompt to be whatever is being executed now in addition to a printf that will show your username # your hostname with your present working directory. You'll have to look up the \033]0; terminal code yourself.

add a permitted path to ghostscipt running configuration

I use a program which create me postscript file before using ps2pdf to make it a readable pdf, i've made a program which add some string to overwrite the company new logo. (The first program can't import image file itself).
I add the string before the before-last line of the file (" showpage").
While running my program to add the logo there is no error.
With the option -dNOSAFER everything is fine, but by default it's set to -dSAFER, and an invalidfileaccess error pop, the files are 6 jpg images alone in their directory.
I don't want to make it run with the -dNOSAFER option on. As it will fully open the file system.
In the documentation I've seen that there is a "permitted path" setting, but i can't find nowhere to set this up. Is it just a command line option to set in the command launching the program ? Or is there a config file for GhostScript / ps2pdf where i can put the path to this directory as permitted path.
in this documentation :
http://www.ghostscript.com/doc/current/Use.htm
I only find
-dTTYPAUSE
Causes Ghostscript to read a character from /dev/tty, rather than
standard input, at the end of each page. This may be useful if input
is coming from a pipe. Note that -dTTYPAUSE overrides -dNOPAUSE. Also
note that -dTTYPAUSE requires opening the terminal device directly,
and may cause problems in combination with -dSAFER. Permission errors
can be avoided by adding the device to the permitted reading list
before invoking safer mode
gs -dTTYPAUSE -dDELAYSAFER -c '<< /PermitFileReading [ (/dev/tty)] >> setuserparams .locksafe' -dSAFER
The quote is just for the context but is this a way to put the permitted path ?
As gs automatically launch with the full system as readOnly there will be no difference ? There is no other find result for PermitFile in this page.
Try adding the required path to the search path with -I (Include) See Use.htm, section 8 How Ghostscript finds files. This should only be a problem if you are using 'run' or similar to read files from another location.
The section on TTYPAUSE is not relevant.

current directory doesn't appear in title bar when running under screen

My xterm $prompt variable in my .tcshrc is:
set prompt="%{\033]0;%m:%~\007%}%{^[[;37;1m%}%B%{^[[;34;1m%}%m%{^[[;34;1m%}:%b%c%# "
The highlighted part above (%{\033]0;%m:%~\007%}) puts the hostname (%m) and the current directory (%~) in the title bar. (At least I think that that's what puts it in the title bar; it's been a while since I fiddled with this prompt).
When I run screen, however, the current directory stops getting updated when I change directories.
My questions:
How can I make this prompt work in screen?
Is there a better way to display the current directory in the title bar?
I am running linux with xterm and tcsh.
I think there is no direct way, because of the way screen works. However screen can display its own status bar, that you can define in .screenrc. Here's mine for instance :
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%=%{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'
Firstly, to make it work you must check where exactly is the line with set prompt=blah-blah in your .tcshrc. For example, the code below that perfectly works in plain xterm would not work under screen in xterm:
switch ($TERM)
case "xterm*":
set prompt="%{\033]0;${HOME:t}#%m:%l:%c08\007%}%{\033[36m%}%l:%c02%#%{\033[0m%} "
# update xterm title to display current cmd in it
alias postcmd 'echo -n "\033]0;${HOME:t}#`hostname`:${tty} \!#:q\007"'
...
because screen by default sets $TERM variable to screen and not xterm! So you must add:
case "screen":
# lame, but prevents an error in screen after 'su - root'
if (! $?WINDOW) setenv WINDOW 1
set prompt="%{\033]0;${HOME:t}#%m:${WINDOW}:%c08\007%}%{\033[36m%}%c02%#%{\033[0m%} "
alias postcmd 'echo -n "\033]0;${HOME:t}#`hostname`:${WINDOW} \!#:q\007"'
...
Secondly, make sure yo have this line in ~/.screenrc:
termcapinfo xterm* 'hs:ts=\E]2;:fs=\007:ds=\E]2;\007'

Resources