iterm2 issue : create new tab with same path of previous current tab BUT 2 tabs are clones and not indepedent - terminal

I have switched from default terminal on MacOS Mojave to iterm2. I have an issue about the opening of a new tab from the current tab.
Indeed, I would like to be in the same path than the previous current tab.
For this, I did the classical procedure, i.e to go to iterm2 preferences and Profile and choose Reuse previous session's directory for new tab :
Then, the issue is that once tab opened, all the other tabs are affected and change from their old path to the path of the new tab: I don't understand what happens and which option to use to prevent this behavior.
Every tab is the same than the others: if I do a cd ~/foo/, then the other tabs will go into foodirectory.
Result worse: if I edit with vim a file in one tab, if I do a cd ~/foo/ in another tab, then the tab associated to the edited file disappears is clearing this edition and shows the same windows than the tab where I did cd ~/foo/: very strange.
I want to keep all the current path for all others tabs except for the new one which must be the same than the previous one from which I do a CMD+T.
I saw on different forums this issue sometimes occurs.
Update 1
From what I have seen, it seems that I have to find a way to create a new session when I do the shortcut CMD+T to get another tab independent from the current one (from which I do CMD+T).
But unfortunately, I didn't find how to create a new session in iTerm2 (inside the iTerm2 - Preferences - profile, I could execute a script that creates this new session). From the moment, you can see the command (/bin/bash that I launch when I open a new tab:
I tried also to build the binary iTerm2 from the sources but issue remains.
Update 2
I tried to use a little apple script to force a new session to be created from current window:
tell application "iTerm2"
tell current window
create tab with profile "Terminology2"
end tell
end tell
(where Terminology2 is a duplicate of profile Terminology (default profile).
But always the same issue, the 2 tabs are not independent: each command in one of 2 is executed on the another one.
Update 3
I keep on trying a solution: for this I removed the macport package and hidden files and directory ~/.iTerm2/.
So I downloaded the iTerm2 zip archive from iTerm2 official website.
Here's a screen capture of my profile :
Is shortcut key necessary in this profile to open new tabs : the issue seems to come from this option since it may not concern the shortcut for a new tab ? CMD+T is already a shortcut for opening an independent tab, isn't it ?
Update 4
Solution finally found. Coming from classic MacOS terminal, I was used to do a shortcut CMD+Shift+-> or CMD+Shift+<- to change of tab.
But by chance, I tried simply the shortcut CMD+-> or CMD+<- and so was able to switch between 2 tabs independent.
So this was an error of beginner into iTerm2's world since I was used to apply old classical shortcut of default terminal.
If someone else makes the same mistake, they will know that it is just a configuration issue of shortcut.

The OP already answered the question in Update 4, but in case anyone jumps right to the answers, the solution was to update the Key Mappings and create two new entries - CMD+SHIFT+LEFT & CMD+SHIFT+RIGHT - with assigned actions of Previous Tab and Next Tab, respectively.
These entries can be created in Preferences -> ${Your Profile} -> Keys, and then clicking on the + icon near the Presets... button.

Do you see the all-pane input icon in the upper right?
Command-Shift-I to toggle it. (that is a capital i)

Sounds like you have Broadcasting enabled. To check:
Toolbar > Shell > Broadcast Input > Send input to current Session Only

Related

Rename tab in MobaXterm for session duration

How can we rename tabs in MobaXTerm for the entire session duration? At the moment, I can right-click and rename the tabs, but as soon as I press enter to get command prompt, MobaXTerm resets tab name to its original default. I have tried changing PS1 env variable with no effect. Please help.
I haven't tried this myself but when you create a profile for a new ssh session, there is a tab "Bookmark settings" and within this tab there is a check box named "Lock terminal title." According to the manual:
Lock terminal title
Terminal title will be set to the session name
If you check this option, any attempt by the shell to set tab title will fail.
Uncheck this option if you want to allow the shell to change tab title.
Looks like you need to open every new tab as a New Session (Click on the "Session" button) and then follow what ks2000 suggested (It works for me).
There is limitation in number of sessions created for non-purchased mobaxterm. When you go for edit the session, red coloured message this message will be displayed. Delete unwanted sessions, unlock terminal title, then it will work. Otherwise purchase mobaxterm.
A bit late, but I came across this and wanted to update it.
I found the answer here:
https://stackoverflow.com/questions/29963545/rename-tab-in-mobaxterm-for-session-duration
I wrote a bash function to quickly handle this for me.
set_title() {
PROMPT_COMMAND="echo -ne \"\033]0;$1\a\""
}
set_title "webserver"
If none of the above works, just go to the sessions tab and click on the session you want to rename (just like when you want to rename a file). You should see the following:
After that, enter the preferred name and hit enter. The following window will occur:
Click yes and voilà!
THIS IS NOT FOR THE SESSION DURATION BUT PERMANENT

Opening up iTerm / Terminal with commands by default.

My current use of iTerm is the following everytime:
- Open up
- cd into my project folder
- open up another tab
- cd into my project folder
- Grunt Watch
- open up another tab
- SSH into live server
This is getting a bit tedious now, is there a simple way to make a one click for all of this to be done? I remember back in the windows days you could create custom command prompt files so it would open up and you could just double click it like an app.
Is there anyway I can do this? I have looked at the profiles and I don't think I can do what I am after with that.
Just need pointing in the right direction.
If you're using iTerm2, there is a feature called Arrangements (see the last entry on the page). With this, you can set iTerm to open a series of profiles (which can be set to run a command at startup, start in a specific directory, run a certain shell, etc.).
It seems that creating one profile for working in a directory, a second for the Grunt Watch, and a third to SSH should be trivial, and once the arrangement is saved, it can be recalled with the press of a hotkey (Cmd⇧R on my install). You can also set this to save split-pane windows if you don't want a separate window for each of these tasks.

iTerm Emacs key codes for Ctrl + <Arrow Keys>

In Emacs on Linux terms and Cygwin, Ctrl + Up/Down causes a long jump (depending on the mode) say one function block down, on iTerm however this does not work I am assuming I need to manually set key codes send?
I guess you are using iTerm 2. Go to Preferences window in iTerm, and check both "Keys" tabs. One is in the main tabs and the second is for each profile. By default, in the "Keys" tab in your profile ^↑ are ^↓ are defined there to send some backward-compatible special keys. Remove them for your profile and you're good to go!
UPDATE: This change doesn't seem to affect your current tab or window. You may need to start a new iTerm window.
Use M-{ and M-} instead.

Open sessions, restore graphical tabs (gvim, windows)

I use gvim and work in tabs. For example, I have 3 tabs open when I :mksession. When I later source it, the files will "open" in buffers, as they are visible in the buffers menu, but it doesn't recreate the tabs.
Looking at the example session.vim, it runs badd for every file, but I can't see anything that creates new tabs. I tried putting au BufAdd * tabnew in my vimrc, but it didn't work as expected.
My .vimrc
Example session.vim
sessionoptions="blank,buffers,curdir,folds,help,resize,tabpages,winsize"
Sometimes the exact right combination of Google search terms will get it for you...
:au BufAdd,BufNewFile * nested tab sball
http://vim.wikia.com/wiki/Open_every_buffer_in_its_own_tabpage
edit: This au command causes Netrw to open a new tab for each directory you browse. A workaround is to run :tab sball after opening a session.
[ When you open session ]
And make your session save command that :mks! next time when You can open session with following.
save session:
1) :mks!
Next open session:
2) vim -S Session.vim
It's so uesful. Enjoy your code in vim.
Thanks.

Saving Meta in OS X Terminal

Since Terminal appeared I've saved as ~/mySrvr.term a modified stock .term file
which opens to execute an ssh to a remote server and to modify the appearance.
I have NOT been able to save "use option key as meta" for emacs-ery; there's no slot for it
in the term file and I'm reluctant to wrestle with a keyboard dictionary file.
Am I missing something simple? How do I get option-as-meta to stick between sessions?
Thanks
If you're on Leopard open up preferences in Terminal.app. There is a tab called Settings which is actually settings for different styles of terminal windows. Make a copy of one of Apple's defaults and change it to your liking and make sure to select the option-as-meta radio button there.
I don't even bother opening term files now, under Leopard you can save any group of windows via the Windows menu and it saves all of their settings and and you can open these backup via the same menu. For example, I have a window group that ssh's into a server in two tabs and the third tab starts up an ssh tunnel.
Not sure if this helps, but when I go Shell -> Export Settings and save the file as a .terminal file, there are a few lines that save my option-as-meta preference:
<key>useOptionAsMetaKey</key>
<true/>
These lines are for a .terminal preference file, not for a .term (which is pretty hard to Google for) so they may not be what you're looking for.

Resources