How do I show the CWD in the iTerm2 prompt? - prompt

Specifically, my prompt is %~%# . When I've descended into many directories, my prompt looks like this:
~/development/games/super-star-trek/lib%
I'd like to shorten the paths like vim's pathshorten function:
~/d/g/s/lib%
How can I do so in iTerm2?
(I'm not using oh-my-zsh)

Related

Load a default shell from vim

When I open up a terminal my default shell looks something like this:
XX-DEV-IM-MM:Ingest david$
However, when I do :term in vim I get something like this for my shell (looks like a root bash shell):
bash-3.2$
Is there a way to use my default system shell rather than this one that doesn't load my .bash_profile and such?

How to set iterm2 Badge from vim?

I want to call the function iterm2_set_user_var VARIABE VALUE from vim/neovim using call system(). However, I get the following.
zsh:1: command not found: iterm2_set_user_var
shell returned 127
This is already done in node.js: How to exec script to set iterm2 Badge from nodejs?
I'm guessing you've defined iterm2_set_user_var as a shell function in your zsh config somewhere. Vim doesn't invoke a login shell with the system function. I think you have two options:
Change shellcmdflag to force a login shell by adding l to the flags currently there. This would affect all :! commands in vim as well.
Define iterm2_set_user_var as an executable somewhere in your $PATH.
Either should work fine.

what is the alternative of `prompt $g` in cygwin

In Windows, I can use prompt $g to hide the path and replace it with > in the command prompt as shown in the below picture,
This is extremely beneficial if the path of the current directory long. I'm looking for similar command for cygwin. Any suggestions?
The shell's prompt is taken from the $PS1 variable. If you want to show just >, set the variable to it
PS1='>'
It might be more convenient to use something like \W which displays the current directory name without path:
PS1='\W> '

How do I change the WinGHCi editor via :set editor?

I want to use Notepad++ instead of Notepad as the editor GHCi calls when I type in :edit. Does anyone know how to do this? I tried
:set editor C:\Program Files (x86)\Notepad++
:set editor "C:\Program Files (x86)\Notepad++"
but none of these work.
Thanks for the help!
The editor is a String, so you need to escape \ as \\, like so:
:set editor "C:\\Program Files (x86)\\Notepad++"
but it's unix/windows agnostic for FilePaths, so you could alternatively do it as
:set editor "C:/Program Files (x86)/Notepad++"
As a side note, it's quicker to type :e instead of :edit; ghci will deduce what you mean from a substring like :ed if there's only one possibility.
Just came across this one. The top answer is correct however I could only get this working by adding -multiInst to the command line i.e:
:set editor "C:/Program Files (x86)/Notepad++/notepad++.exe" -multiInst
or just
"C:/Program Files (x86)/Notepad++/notepad++.exe" -multiInst
in the settings dialog of WinGHCi which opens a new notepad++ instance on :e.
I would guess that Notepad++ should be on your $PATH. If you can run Notepad++ from a newly-opened terminal, then you're good. Then use :set editor Notepad++ in ghci.
You can add a new system environment variable called EDITOR to your system environment variables if you want to use the editor you like permenantly.
Attentions:
You should add it to your system environment variables, not user's environment variables.
EDITOR should be all capitalized.
Most importantly, the value of this variable should be:
a Using double backslashes.
b keep the quotation marks! (like this: "C:\Users\\AppData\Local\Programs\Microsoft VS Code", I think other variables might not have or need this quotation marks, but it NEEDs in this case.)

How to start Gvim from Command Prompt?

I tried to start gvim using start command like this
start gvim.exe
But it doesn't work for gvim, although it does work for firefox.exe. My questions are-
How can I start gvim from command prompt?
Why start command doesn't work for gvim.exe?
Are there any additional parameter that I can use when starting gvim from command prompt?
Completely different, so a separate answer:
Actually, -- I just remembered -- Vim isn't normally added to the path variable, it's run through .bat files in C:\Windows.
From another answer on StackOverflow:
When you install gVim: Please make sure Create .bat files for
command line use is checked. It'll create several .bat files in
C:\Windows\:
C:\>cd %windir%
C:\WINDOWS>dir /b *.bat
evim.bat
gview.bat
gvim.bat
gvimdiff.bat
view.bat
vim.bat
vimdiff.bat
vimtutor.bat
This is because gvim.exe is not in your PATH list. If you know which directory gvim.exe resides, add this directory to your PATH list. This can be done by typing the following in an Explorer address bar:
Control Panel\System and Security\System
Then press Advanced system setings, then Environment Variables. The PATH is a list of directories separated by a ;.
Try typing just "gvim" instead of "start gvim.exe". That works for me. Vim isn't in my path environment variable.

Resources