MacOS Big Sur not setting the COLUMNS environmental variable - terminal

I was having trouble using the shell vi editing mode - the cursor would move back a line sometimes. I finally tracked it down - Terminal is no longer setting COLUMNS, so the shell defaulted to 80.
I had a comment in my .profile that COLUMNS use to be set by TERMINAL, but now it isn't. I can't find anything in the Preferences that would appear to enable that.
Anyone know what happened, and how one might fix it. The original idea was users would resize windows, and pass the new size down to the shell so editing would work properly.

export COLUMNS=<number>
in your .bashrc.

Related

Clear terminal without clearing first line of multi-line prompt

I'm trying to setup the terminal on my new Mac to match the behavior of my old Mac, however I have run into an issue with my multiline prompt that has me stumped. I remember having this issue when I setup my old Mac several years ago, however I don't remember how I solved it.
My prompt (without color) looks like this:
╭─username ~ 130 ↵
╰─
When I press ⌘commandK in iTerm2 on my old Mac it clears the terminal window so that both lines of the prompt are shown at the top.
When I press ⌘commandK in iTerm2 on my new Mac it clears the terminal window so that only the second line of the prompt is shown at the top.
I have tried checking everything I could think of, I have checked:
Every dot file/directory in my home directory (copied them to the new Mac).
iTerm2 settings.
System settings (primarily keyboard shortcuts).
Various websites with instructions about setting up multi-line prompts.
Interestingly I have discovered that if I type clear iTerm2 will clear the screen and leave the top line showing on both Macs. However it first clears the entire screen, including the prompt, before bringing the prompt back (looks bad imo). However since it works differently ⌘commandK does I don't think that's what my old Mac is doing.
It's possible that I installed some program/script that somehow does this, but if so I'm not finding it locally or referenced online.
Does anyone know how I can get ⌘commandK working to clear the screen while keeping the top line of my prompt? I still have the old Mac so I can check/compare anything on it to the new Mac if there are any guesses about what settings I changed.
Edit:
I was able to find something that worked, however if anyone has any other suggestions I'll be happy to try them and accept any that I can make work that are less hacky than this (e.g. don't require another 3rd party app).
Edit: This doesn't work while a command is running, nor does it clear the scrollable history. So it's better than nothing but still doesn't behave like I want it to.
After coming back to my question SO associated a new question with an answer I was able to make work, although it feels extra hacky and wasn't what I had working before.
I found this answer which suggests using ⌃controlL to clear the screen. That does exactly what I want it to do (leaves the top prompt visible and doesn't flash) but with the wrong keybinding. Fortunately I was able to use an app I already have installed (BTT) to make ⌘commandK map to ⌃controlL only in iTerm2.

zsh name in terminal changed to a number when logged in

I used to see myname#my-Macbook... when I open my Terminal, but recently it changed to myname#192. Why did this happen, and is there a way to change it back? Thanks!
Check out what hostname returns. If it returns that number, search for changing the hostname. If not, your shell prompt has gotten messed up, and an easy way to fix it is to trash your shell config (.zshenv, .zshrc, etc).

How can I change the newline code for fish shell

I'm using windows 10 and installed cmder, using the fish shell with omf Theme fishface.
But every new row, it will show a new row Mark as this picture. Screenshot for new row mark
How can I get rid of this mark?
** didn't work if I change to another theme too.
Additional information without cmder.
Screenshot with cmd.exe + bash + fish
You can't disable that feature. The fish shell uses a heuristic (inherited from zsh) to determine if the output of the preceding command ended with a newline. If it doesn't it displays the Unicode U+23CE symbol (what you're seeing) or a tilde. Search the code for the symbol PROMPT_SP. Commit 58347d49 that I wrote and merged 2016-12-23 fixed that behavior for the Windows ConEmu terminal emulator. See issue 789. Based on your problem description it appears that heuristic does not work correctly in the cmder terminal. This probably means that terminal emulator has a bug since it doesn't behave like nearly all the terminals that fish runs on. Feel free to open an issue

Vi for OS X won't show -- insert -- on status

I have tried many things such as add "set showmode" in .vimrc file and start vi with the command "vim" instead of just "vi". Nothing seems to work. I have another Mac and in that one the --Insert-- status does show up.
Any help is appreciated.
Thanks!
vim will not show the mode if (later) in the settings you have
set compatible
That cancels and/or overrides most of the vim extensions. See these for discussion:
In a .vimrc, is set nocompatible completely useless?
Setting vim filetype with modeline not working as expected
I was finally able to fix the problem.
It seems that the status was always there but the text color was the same as the background (black). As soon as I changed the theme color, I was able to see the status --Insert--.
if your trying status lines and term colours you might find this useful.
https://github.com/FallenAngelTodd/vim-status
lots used for setting different modes in the status line?

Vim under mac does not behave as expected

I recently got a mac. I was previously working on a laptop with ubuntu and I was using vim.
I now will discuss about vim in console (iTerm2 or the default terminal) and macvim.
The problem is that some binding don't work under mac. For example I had CTRL left/right for navigating between splits, CTRL up/down to move lines or blocks of code up and down, etc. They don't work anymore.
I had a bunch of plugins (nerdtree, powerline, etc.) that now look weird. Powerline doesn't display special characters in macvim and in terminal they are question marks.
In console, nerdtree looks weird and it doesn't display the special triangle character. If I hit return to open a file selected from nerdtree, it doesn't do anything. In macvim, it works ok.
Is there any guide on how to use vim on mac? Or what is the recommended way?
Nerdtree : let g:NERDTreeDirArrows=0
Powerline : Take a look at the part of strange characters in the document https://github.com/Lokaltog/vim-powerline
Navigating within splits with Ctrl + arrows work on mine. Can you post your vimrc, or try running vim without any configuration.
Ctrl+arrows to move lines and block doesn't work on mine.
Did you check which key was sent by your terminal to vim ?
Did you tried to set it manually ?
I had similar problems with emacs, including one keybinding I'm still not able to reproduce :(
I have the exact same config on my Mac and a Windows box at work, my Ubuntu box at home and a couple of VPSes. It works exactly the same on every platform in GVim/MacVim or in plain Vim.
Unfortunately I don't use either NERDTree nor Powerline but Vdt's answer seems to have all the info needed.
Some of the behaviors you describe are custom mappings. You should show us your ~/.vimrc (the old one on linux and the new one on the Mac, if there are differences) so that we can help you make it more portable.
Also, "looks weird" means nothing: please add a screenshot or two.

Resources