Showing posts with label iterm2. Show all posts
Showing posts with label iterm2. Show all posts

8.10.2020

iterm2 Clear all Sessions on Current Tab

On mac, save this as /Users/[username]/Library/Application Support/iTerm2/Scripts/AutoLaunch/clear_current_tab.py
#!/usr/bin/env python3

import asyncio
import iterm2
import time

async def main(connection):
    app = await iterm2.async_get_app(connection)
    @iterm2.RPC
    async def clear_current_tab():
        code = b'\x1b' + b']1337;ClearScrollback' + b'\x07'
        window = app.current_terminal_window
        tab = window.current_tab
        for session in tab.sessions:
            await session.async_inject(code)
    await clear_current_tab.async_register(connection)

iterm2.run_forever(main)
Now bind it to a keystroke in Prefs > Keys by selecting the action Invoke Script Function and giving it the invocation clear_current_tab().

7.21.2017

Mac Cheat Sheet

1. Install sshpass
$ brew install http://git.io/sshpass.rb

2. Using iTerm2, configure profiles and use sshpass so there's no need to enter passwords for ssh, follow this post for configuring iTerm2. What worked for me is in Command, select "Login shell", then send text at start:
sshpass -p 'password' ssh -o StrictHostKeyChecking=no user@server