Readline does not read user config specified in INPUTRC variable [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I am trying to change the location of my inputrc. The docs say that it reads the config location from the INPUTRC environment variable
Readline is customized by putting commands in an initialization file (the inputrc file). The name of this file is taken from the value of the INPUTRC environment variable
I exported this variable in my ~/.bash_profile
export INPUTRC="~/.config/readline/inputrc"
and added the following lines to ~/.config/readline/inputrc
$include /etc/inputrc
# Case insensitive tab completion
set completion-ignore-case on
# Single tab partially completes and shows all options
set show-all-if-ambiguous on
# shift + arrows to go back and forth one word at a time
"\e[1;2D": backward-word
"\e[1;2C": forward-word
# Cycle through completions inline
Tab: menu-complete
"\e[Z": menu-complete-backward
Now if i try to open a new bash session, none of these options seem to have taken effect. It works as expected if I put them in ~/.inputrc with or without the INPUTRC variable exported. I've also tried exporting it from ~/.bashrc and ~/.profile, neither has worked.
I could add these lines to my bashrc using bind but that would mean that other programs that use readline wouldn't share these options.

Related

Installed Go, but command go not found. Does work on one terminal linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I installed go on linux yesterday. It worked fine and downloaded some tools and they worked also. I left the terminal open and when I came back today go stopped working... In the left terminal go works and does everything... But when I open another terminal and type go it said "command go not found" (see screenshot).
Can anyone help me please? I don't know what I did wrong or what went wrong...
Go works on the left terminal, not right...
tl;dr
Add the export command you ran to the $HOME/.bashrc file (preferably at the end).
When you installed go you probably ran the export command to add the location of go binaries to the PATH variable. But here's the thing. The PATH variable is, effectively, reset to the previous value when you open the new terminal. To make it permanent you need to add the command to your shell's rc file.
What's an rc file?
When you open the terminal it uses a rc (short for run commands) file and runs the commands in this file. The name of the file depends on the shell you are using.
If you are using bash, the name would be .bashrc. If you are using zsh, the name would be .zshrc.
You can run echo $PATH in both the terminals and see the PATH variable in which go runs would have the location of go binaries and the other wouldn't.
So to make this permanent, add the export PATH=$PATH:{PATH_GO_BINARIES} to the rc file. And, then, whenever a new terminal is opened, the PATH variable would be updated to contain the location of go binaries.

How to change the username displayed within terminal window on Linux Mint? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I am trying to change my current username on Linux Mint that shows up when I open a terminal window.
Currently:
john#myLinux
I want to change to:
gary#myLinux
I have tried:
(1) Start -> Settings -> Account Detail and altered the 'name' field.
(2) The steps mentioned here: https://askubuntu.com/questions/34074/how-do-i-change-my-username
(3) Altering the passwd file: https://www.cyberciti.biz/faq/understanding-etcpasswd-file-format/
Option #3 seems to affect the username displaying in the terminal window but causes issues with logging in(my password becomes incorrect).
How can I successfully change the username that is displayed in my terminal window on Linux Mint OS?
This assumes you are using bash, and might not work for a different shell.
This will only change the terminal prompt text, it will not update your user account or change any other system files.
in a terminal type DEFAULT=$PS1
next type PS1='gary#\h\$ '
last of all, if you want to return to your default prompt type PS1=$DEFAULT
Note 1: Make sure to save these settings in your .bashrc file under the home directory to have changes persist across terminal sessions.
Note 2: In step 2, \h tells the bash prompt to print out the computer hostname, the \$ prints out show the (#) symbol if you're ROOT otherwise show the ($) symbol.
More information can be found here: https://www.howtogeek.com/307701/how-to-customize-and-colorize-your-bash-prompt/

:wq! results in E212: Can't open file for writing Press ENTER or type command to continue [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I am just trying to exit my vim file with :wq! but it gives me the error:
E212: Can't open file for writing
Press ENTER or type command to continue
I press enter or type anything and it goes back to editing the file. Is there something wrong?
I am now stuck in my text editor.
You can get more details about the error via :help E212:
For some reason the file you are writing to cannot be created or overwritten.
The reason could be that you do not have permission to write in the directory
or the file name is not valid.
If you don't need the changes any longer, just :q! and be done with it. For multiple Vim arguments, there's also :qall!.
If you do want to keep the changes, one approach is to investigate the permissions issue, e.g. in another terminal or via the file explorer, and fix the issue (e.g. via chmod / chown).
Alternatively, you can persist the changes elsewhere via :w /tmp/changes, then :quit Vim, and then resolve the problem outside of Vim.
To address the "I'm stuck in Vim" (assuming it's not possible / tedious to start another session on the system): :suspend puts Vim in the background, and drops you into the original shell you started Vim from. :shell starts a new shell from inside Vim, to which you return via exit.

'usr/bin' is not included in the path environment [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
Whenever I start a new terminal and try to run a command, I get this error.
I have found out that it can be solved with export PATH=/usr/bin:/bin, but it has to be done for each terminal I open. In the etc/environment file, the path is correct, so hence I do not understand what is wrong.(But this error appeared after I added some lines to bashrc and paths to have some shortcuts for ruby, rails , git ; ( was following a course on Coursera )).
How can this be fixed?
What's happened here is you've clobbered your PATH variable. Your PATH is pretty important, whenever you enter a command your shell (usually bash), will check each of the directories specified in your PATH for a program of the same name.
Each directory specified in your path is separated by a colon :, and a minimal PATH variable usually looks something like /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin.
When you have the line export PATH=/usr/bin/git at the end of your .bashrc you are telling your shell that you only want to search /usr/bin/git for commands.
Instead, the line export PATH="$PATH:/usr/bin/git" will tell your shell to search all of the directories previously specified in your shell, and then search /usr/bin/git.
Another thing to note is that your shell will search the directories in your PATH in the order they're specified, and use the first matching command found, so the order that directories are specified in the PATH can matter too.

How do I format my zsh prompt based on a condition? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I'm using the answer given here: How do zsh ansi colour codes work? to format and add color to my zsh prompt.
Is there any way to format the prompt based on some conditions?
For example, if the hostname has the word PROD in it, then I'd like my prompt to have a red background. Otherwise, I'd like no background, and bold green text.
Its easy to do now you can use the conditional substring
This is the syntax %(condition.ifTrue.ifFalse)
export PROMPT="%(%m==PROD.ifTrue.ifFalse)"
You can set a precmd function that resets your prompt just before it is displayed each time.
set_red_prompt_background () {
if [[ ${(%):-%M} = *PROD* ]]; then
PS1="%K{red}$PS1%k"
else
PS1="%F{green}%B$PS1%f%b"
fi
}
typeset -a precmd_functions
precmd_functions+=(set_red_prompt_background)
This isn't tested, so I'd be surprised if it works as is. But here's how it's intended to work.
${:-foo} is a special type of "parameter" expansion which just expands to the word following the :-. Seems useless at first...
${(%):-%M} is the same as above, but has the (%) flag to instruct zsh to process any prompt escapes found in the expansion. This turns into a fancy way of getting the full host name that would appear in the prompt using the %M escape.
Check if it matches the pattern *PROD*, i.e., does the host name contain PROD.
Take whatever the value of PS1 is, and wrap it in %K{red}...%k to make the background red. Note that this might override any background colors already set in PS1.
Add set_red_prompt_background to the list of functions executed prior to displaying the prompt. If you add any functions after this, they could potentially override the color you set here.
Edit .zprofile file in your root Directory, with conditions applied on the specific user logged into.

Resources