mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-22 04:51:12 +02:00
Plugin for iTerm2 on OSX
iTerm2 is a popular terminal emulator for OSX (https://www.iterm2.com). The plugin currently implements one function, iterm2_profile, which allows easily changing the currently selected user settings profile, without creating a new tab or window, just by calling the function. For example, this is handy for switching from a dark to a light colored profile without having to re-open anything. In addition, it also works within tmux running inside iTerm2.
This commit is contained in:
parent
d848c94804
commit
ec98cb6972
1 changed files with 38 additions and 0 deletions
38
plugins/iterm2/iterm2.plugin.zsh
Normal file
38
plugins/iterm2/iterm2.plugin.zsh
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
#####################################################
|
||||||
|
# iTerm2 plugin for oh-my-zsh #
|
||||||
|
# Author: Aviv Rosenberg (github.com/avivrosenberg) #
|
||||||
|
#####################################################
|
||||||
|
|
||||||
|
###
|
||||||
|
# This plugin is only relevant if the terminal is iTerm2 on OSX.
|
||||||
|
if [[ "$OSTYPE" == darwin* ]] && [[ -n "$ITERM_SESSION_ID" ]] ; then
|
||||||
|
|
||||||
|
###
|
||||||
|
# iterm2_profile(): Function for changing the current terminal window's
|
||||||
|
# profile (colors, fonts, settings, etc).
|
||||||
|
# To change the current iTerm2 profile, call this function and pass in a name
|
||||||
|
# of another existing iTerm2 profile (name can contain spaces).
|
||||||
|
function iterm2_profile() {
|
||||||
|
# Desired name of profile
|
||||||
|
local profile="$1"
|
||||||
|
|
||||||
|
# iTerm2 escape code for changing profile
|
||||||
|
local iterm2_code="\x1b]50;SetProfile=$profile\x7"
|
||||||
|
|
||||||
|
# If we're in tmux, a special escape code must be prepended
|
||||||
|
# so that the iTerm2 escape code is passed on into iTerm2.
|
||||||
|
local prefix=''
|
||||||
|
local suffix=''
|
||||||
|
if [[ -n $TMUX ]]; then
|
||||||
|
prefix='\033Ptmux;\033'
|
||||||
|
suffix='\033\\'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# send the sequence
|
||||||
|
echo -n "${prefix}${iterm2_code}${suffix}"
|
||||||
|
|
||||||
|
# update shell variable
|
||||||
|
ITERM_PROFILE="$profile"
|
||||||
|
}
|
||||||
|
|
||||||
|
fi
|
||||||
Loading…
Add table
Add a link
Reference in a new issue