Terminal configuration is incorrect - terminal

I'm having issues with two parts of my Terminal installation in particular.
The first is the prompt area. Look at how on each new line it says 108% instead of >. I'd like to know how I can switch that back to >.
![Image of Terminal][1]
The second issue is that I'm having issues setting my $EDITOR variable for tmux to work.
I've worked and set up the .tmux.conf file, and used the following line to attempt to set the editor:
EDITOR = "vim"

I was able to solve this issue with the following:
For the first issue (108 was set as my prompt), I went into my .zshrc file and added export PS1="%/$ ", then saved the file. My command prompt instantly changed back to normal, and I was fine.
For the second issue (echo $EDITOR was not returning anything, so tmux was not generating new projects), I simply entered my .zshrc file, and I added export before EDITOR so that the line looked like export EDITOR="vim".

Related

Environment Variables macOS & WIndows

In Windows' Environment Variable Tab, the User Variable and System Variables are separated. I have a MacBook Pro and would like to add new 'user' variables like Windows. Is this possible? I mean I found there are temporary variables that can be created in the Terminal, but if that Terminal is closed, the variables are gone. I found a way to do a permanent variable, but do not want to mess things up in the core of the macOS. Are there any recommendations?
If you set variables in the ~/.bash_profile file, they will always exist since this file is automatically run every time you open Terminal.
To edit it:
vim .bash_profile
(i to insert text, esc to exit insert mode, :q! to discard and quit, :x to save and quit)
Then add:
export VARIABLE_NAME=value
Save and quit the editor (:x). Then to check if it worked:
echo $VARIABLE_NAME
When the terminal is bash, editing the .bash_profile works.
If you're using zsh, then edit
~/.zsh and add the command as
""export variableName = value"" in to the file
Now, run
""source ~/.zsh""

Basic command lines on Mac terminal not working

I changed the bash profile while trying to install mongodb and none of my command lines are working on terminal. I read online that I need to fix the $PATH but I can't even access it when none of my commands are working.
Help?
Mistakenly I also ran into same problem where to resolve this I had to reset my PATH variable to basic settings as below :
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin"
Once you set PATH variable now you can open the .bash_profile file in same terminal session only and make changes accordingly. This will resolve your problem.
Ok I found the answer from here:
"Open Terminal, and go to File (or Shell) -> New Command. Type in open -e .profile (or substitute some other file instead of .profile), and hit Run. That should open TextEdit with the file you want to fix; you can remove the offending lines there."
in my case i typed in nano .bash_profile and that allowed me to edit my bash profile and fix the issue.
can't use terminal from error in .bash_profile
Run this in terminal:
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

Change in the hostname/user in Terminal in Leopard OSX

My terminal previously showed subalcharla$ at the command line.
The terminial is now showing subalcharla#subal-charlas-macbook ~ $.
How do I go back to the original setting?
What is the difference between the two?
How did this get changed without my doing so?
At the end of ~/.profile add the line
export PS1='\u$ '
to get your old prompt back.
To do this you can type
nano ~/.profile
which will bring up a text editor. Press down until you get to the bottom of the file. Hit Enter to create a new line, and paste in
export PS1='\u$ '
Press Control+X to exit the editor and say "yes" when asked if you want to save. Now restart your terminal and your prompt should be restored.
The first prompt you gave shows your username, the second shows your username and hostname. There is no error and the functionality of your bash shell is not changed by changing the prompt.
Something must have changed your PS1 environment variable, maybe a system update or the installation of software. It's probably benign though.
I don't know how it got changed, but it's controlled by some symbol definitions. Use "man bash" in the terminal and search for the section called "PROMPTING". There are symbols named PS1-to-4 that it uses to construct the prompt.

Removing no such file command from OSX terminal startup [duplicate]

This question already has an answer here:
How to restore .bash_profile on a mac? None of my unix terminal are working [closed]
(1 answer)
Closed 8 months ago.
Whenever I start a new Terminal session, the window opens up with a command:
'-bash: cd: /Users/yourusername/Library/lejos_nxj: No such file or directory'.
I want to remove that line from coming up on the prompt, so I deleted the Terminal plist file and sent hard resets, but nothing has worked for me so far.
Is there anything I haven't tried yet?
You've probably got something in your ~/.profile, which is automatically executed when you open a Terminal.
If you did not set anything in there, do
rm ~/.profile
in a Terminal and this should disappear.
If you think that something important may be in there, do
open -a TextEdit ~/.profile
(or change TextEdit to your preferred editor) to view and edit the file.
That line is probably in either your ~/.bashrc file or your ~/.profile file. I would check those two files first (and they are both hidden because of the period initial character).
Edit: I just checked my OS X system, and I don't have ~/.bashrc (but you may).
You could try a terminal replacement (Just recently read about this one, iTerm2) it might
resolve your problem by using its own default startup settings.
If it is anything like Linux the ~/.bashrc and ~/.profile are used when you open your terminal.
It seems that most people assume it is in some init file but its not clear which are included. Once your shell does come up (ignore errors) -try this:
script
bash -l -x
exit
exit
Now you should have a file called typescript which will have debug info showing most if not all of what the shell has executed when coming up in login mode. You could for instance do grep source typescript to see which files were involved OR you could find refrences to nxj etc.
p.s. I assume your clearing of the plist would clear the preferences, but wouldn't hurt to see if the relevant command is in 'Terminal-> Presences->Settings->Shell->Run Command' for any of the terminal window presets

How can I invoke VIM with C-X e for long, complex, tricky commands?

I found an awesome tip here. You can "[r]apidly invoke an editor to write a long, complex, or tricky command". However, when I press the key combination above, I get Emacs open. I would like to switch it to Vim. How can I invoke Vim with C-X e?
[1. Problem SOLVED by Brian Cambell]
export EDITOR=vim
Add to your .bashrc or appropriate shell rc file
[2. Problem SOLVED thanks to Pax]
I was unable to get the tricky command back to Bash. The errors were:
> Error detected while processing BufRead Auto commands for "*":
> E117: Unknown function: JumpToLastPosition
Quotes in .vimrc solved the second problem. I am still unsure about the part in my .vimrc:
" augroup misc
" autocmd!
" autocmd BufReadPost * call JumpToLastPosition()
" autocmd FileChangedShell * call WarningMsg("File changed outside of vim")
" augroup end
[3. Problem]
What do the above part in .vimrc do?
On most Linux installs (all the ones I tested), bash recognizes both the Emacs and Vi command history keys (or you can use "set -o vi" to force it).
So, you can just use the vi-mode "<ESC>v" to to enter visual mode, this will start editing in a Vim session.
To run the command, you just save and exit from Vim ("ZZ" or ":wq"). To cancel the command, you need to delete the contents, save and exit ("1GdGZZ").
In addition to running it by exiting, you can also save it while in the editor to another location (":w /tmp/myscript").
Keep in mind that visual mode will work with the currently selected line so you don't have to start with a blank command ("<ESC>v"). You can use the normal vi-mode tools to select a line from the history first and then enter visual mode ("<ESC>kv" for last command, "<ESC>/grep<ENTER>nnv" for third-last grep command and so on).
Using this method has the advantage of not changing the "EDITOR" variable which may be used for other things (unless you want Vim for everything, which is a very sensible position to take IMNSHO).
Update:
Regarding your error, posted after the question:
JumpToLastPosition() is the function called by Vim for all files to put the cursor where it was when you last edited the file. I'm going to assume you're actually getting this error when the editing starts, not when you exit, since this is the auto function following a buffer read.
Can you start a "normal" vim session ("vim xx.txt" and then "vim xx") without this error occurring? You may find you get the same problem (and possibly only on the last one).
If you do have the same problem, you need to look at your startup files. It's possible the autocmd for BufRead is broken somehow. Have a look inside your vimrc and you filetype.vim files to see where that function is called and/or defined (I suspect it's called but not defined and that may be a mismatch between the two files or one of them has been damaged).
export EDITOR=vim
Add to your .bashrc or appropriate shell rc file
The link that you provided contains the answer:
Next time you are using your shell, try typing ctrl-x e (that is holding control key press x and then e). The shell will take what you've written on the command line thus far and paste it into the editor specified by $EDITOR.
You need to set the EDITOR environment variable (like #Brian Campbell)

Resources