integrate terminal in Alfred

[!NOTE|label:references:]

  • v0.7

    -- This is v0.7 of the custom script for AlfredApp for iTerm 3.1.1+
    -- Please see https://github.com/stuartcryan/custom-iterm-applescripts-for-alfred/
    -- created by Sinan Eldem www.sinaneldem.com.tr
    
    on alfred_script(q)
      if application "iTerm2" is running or application "iTerm" is running then
        run script "
          on run {q}
            tell application \"iTerm\"
              activate
              try
                select first window
                set onlywindow to true
              on error
                create window with default profile
                select first window
                set onlywindow to true
              end try
              tell the first window
                if onlywindow is false then
                  create tab with default profile
                end if
                tell current session to write text q
              end tell
            end tell
          end run
        " with parameters {q}
      else
        run script "
          on run {q}
            tell application \"iTerm\"
              activate
              try
                select first window
              on error
                create window with default profile
                select first window
              end try
              tell the first window
                tell current session to write text q
              end tell
            end tell
          end run
        " with parameters {q}
      end if
    end alfred_script
    

tab

setup a colorful tab

pick colors

references:

> $ while read i; do
>   c=$(echo $i | awk -F':' '{print $1}');
>   echo === $c === ;
>   tabset --add m-$c $c;
> done < csscolors.js

$ tabset --list
tabset list
1.10.5.4.1 -- tabset list

add favor color to a file (~/.marslo/.colors)

$ echo "<color-name>" >> ~/.marslo/.colors

get color hex (for it2setcolor)

[!TIP] download original csscolor.js if necessory:

$ curl -fsSL -O https://raw.githubusercontent.com/jonathaneunice/iterm2-tab-set/master/csscolors.js
$ while read -r i; do
>   rgb=$(grep -E "\s$i:" csscolors.js | sed -re "s:.*\[(.*)\],?$:\1:";)
>   hexc=$(for c in $(echo ${rgb} | sed -re 's:,::g'); do printf '%x' $c; done)
>   echo -e """$i :\t$rgb :\t$hexc"""
>   echo "$hexc" >> ~/.marslo/.it2color
> done < ~/.marslo/.colors

result:

$ ./rgb2hex.sh
yellowgreen   : 154, 205, 50  : 9acd32
wheat         : 245, 222, 179 : f5deb3
tomato        : 255, 99, 71   : ff6347
steelblue     : 70, 130, 180  : 4682b4
tan           : 210, 180, 140 : d2b48c
sandybrown    : 244, 164, 96  : f4a460
plum          : 221, 160, 221 : dda0dd
palegoldenrod : 238, 232, 170 : eee8aa
palegreen     : 152, 251, 152 : 98fb98
navajowhite   : 255, 222, 173 : ffdead
olive         : 128, 128, 0   : 80800
moccasin      : 255, 228, 181 : ffe4b5
chartreuse    : 127, 255, 0   : 7fff0
palegreen     : 152, 251, 152 : 98fb98
mediumorchid  : 186, 85, 211  : ba55d3
royalblue     : 65, 105, 225  : 4169e1
olivedrab     : 107, 142, 35  : 6b8e23
khaki         : 240, 230, 140 : f0e68c

show color in iterm2

$ cat << 'EOF' > ~/.profile
# iTerm2 tab titles
function itit {
  if [ "$1" ]; then
    unset PROMPT_COMMAND
    echo -ne "\\033]0;${1}\\007"

    if [ 2 -eq $# ]; then
      case $2 in
        [cC] )
          it2setcolor tab $(shuf -n 1 ~/.marslo/.it2colors) || echo
          ;;
        [bB] )
          printf "\e]1337;SetBadgeFormat=%s\a" $(echo -n "${1} \(user.gitBranch)" | base64)
          ;;
        [bB][cC] | [cC][bB] )
          printf "\e]1337;SetBadgeFormat=%s\a" $(echo -n "${1}" | base64)
          it2setcolor tab $(shuf -n 1 ~/.marslo/.it2colors) || echo
          ;;
      esac
    fi

  else
    export PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/\~}\007";'
    printf "\e]1337;SetBadgeFormat=%s\a" $(echo -n "" | base64)
    it2setcolor tab default
  fi
}
EOF
  • usage:
    $ itit 'title-string-here' [c][b]
    
  • result:
itit <string> c
1.10.5.4.2 -- itit c
itit string bc
1.10.5.4.3 -- itit string bc

hidden settings

  • to change the number of entries in the autocomplete menu:

    $ defaults write com.googlecode.iterm2 AutocompleteMaxOptions -int 10
    
  • to change the number of coprocess commands remembered:

    $ defaults write com.googlecode.iterm2 "Coprocess MRU" -int 10
    
  • to preserve whitespace in selections copied to the pasteboard:

    $ defaults write com.googlecode.iterm2 TrimWhitespaceOnCopy -bool false
    
  • When you open a file from the finder in iTerm2 (e.g., by double-clicking a shell script), it will either open in a window or a tab. By default, it opens in a tab. You can change this with:

    $ defaults write com.googlecode.iterm2 OpenFileInNewWindows -bool true
    
  • quite iTerm2 when the last session is closed

    $ defaults write com.googlecode.iterm2 MinRunningTime -float 10.0
    
  • increase the delay before it attempts to reconfigure itself after a change of monitors

    $ defaults write com.googlecode.iterm2 UpdateScreenParamsDelay -float 1.0
    
  • to change the number of paste history entries saved:

    defaults write com.googlecode.iterm2 MaxPasteHistoryEntries -int 20
    
  • pastes (both regular and slow) are done by splitting the text to paste into chunks. there is a delay between the transmission of each chunk. to change the speed that "paste" pastes at:

    $ defaults write com.googlecode.iterm2 QuickPasteBytesPerCall -int 1024
    $ defaults write com.googlecode.iterm2 QuickPasteDelayBetweenCalls -float 0.01
    
  • to change the speed that "paste slowly" pastes at:

    $ defaults write com.googlecode.iterm2 SlowPasteBytesPerCall -int 16
    $ defaults write com.googlecode.iterm2 SlowPasteDelayBetweenCalls -float 0.125
    
  • to disable using the pinch gesture to change font size:

    $ defaults write com.googlecode.iterm2 PinchToChangeFontSizeDisabled -bool true
    
  • to keep LC_CTYPE from being set when locale environment variables are set:

    $ defaults write com.googlecode.iterm2 DoNotSetCtype -bool true
    
  • to allow Growl notifications to be posted for the current tab:

    $ defaults write com.googlecode.iterm2 GrowlOnForegroundTabs -bool true
    
  • to tune smart cursor color settings:

    $ defaults write com.googlecode.iterm2.plist SmartCursorColorBgThreshold -float 0.5
    $ defaults write com.googlecode.iterm2.plist SmartCursorColorFgThreshold -float 0.75
    
  • to allow a three-finger tap to act like a three-finger click:

    $ defaults write com.googlecode.iterm2.plist ThreeFingerTapEmulatesThreeFingerClick \
    -bool true
    
  • to change the set of characters that are considered part of a URL (besides alphanumerics):

    $ defaults write com.googlecode.iterm2.plist URLCharacterSet -string \
    ".?\\/:;%=&_-,+~#@!*'()|[]"
    
  • to use some experimental optimizations that will improve performance (safety not guaranteed):

    $ defaults write com.googlecode.iterm2.plist ExperimentalOptimizationsEnabled -bool true
    
  • to tweak tab sizes:

    $ defaults write com.googlecode.iterm2 UseUnevenTabs -bool false
    $ defaults write com.googlecode.iterm2 MinTabWidth -int 75
    $ defaults write com.googlecode.iterm2 MinCompactTabWidth -int 60
    $ defaults write com.googlecode.iterm2 OptimumTabWidth -int 175
    
  • to change your search engine:

    $ defaults write com.googlecode.iterm2 SearchCommand \
    -string "http://google.com/search?q=%@"
    
  • to adjust the speed of the animation of the hotkey window's appearance and disappearance:

    $ defaults write com.googlecode.iterm2 HotkeyTermAnimationDuration \
    -float 0.25
    
  • to adjust the amount of dimming of split panes. Set the value to a floating-point number between 0 (no dimming) and 1 (complete dimming). The default is 0.15:

    $ defaults write com.googlecode.iterm2 SplitPaneDimmingAmount \
    -float 0.25
    

advanced paste

remove the last newline character when pasting

[!NOTE|label:see also:]

\s*\r\r*$

# verify
$ defaults read com.googlecode.iterm2 PasteSpecialRegex
\\s*\\r\\r*$
$ defaults read com.googlecode.iterm2 PasteSpecialSubstitution
advanced paste
1.10.5.4.4 -- advanced paste
paste without newline
1.10.5.4.5 -- paste without newline

iTerm2 Python REPL

Welcome to the iTerm2 Python REPL!

This is an interactive Python interpreter where you can experiment with
scripts. Unlike standard Python interpreters, you can use "await" not inside an
async function. Here's an example script to try:

import iterm2
connection=await iterm2.Connection.async_create()
await iterm2.Window.async_create(connection)

⌘-click here for iTerm2 Python API Docs

>>>

theme

[!NOTE|label:references:]

$ export LS_COLORS='no=00:fi=00:di=01;31:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:'

$ echo $LS_COLORS
no=00:fi=00:di=32:ow=37:ln=35:pi=30;44:so=35;44:do=35;44:bd=33;44:cd=37;44:or=05;37;41:mi=05;37;41:ex=01;31:*.cmd=01;31:*.exe=01;31:*.com=01;31:*.bat=01;31:*.reg=01;31:*.app=01;31:*.txt=32:*.org=32:*.md=32:*.mkd=32:*.h=32:*.hpp=32:*.c=32:*.C=32:*.cc=32:*.cpp=32:*.cxx=32:*.objc=32:*.cl=32:*.sh=32:*.bash=32:*.csh=32:*.zsh=32:*.el=32:*.vim=32:*.java=32:*.pl=32:*.pm=32:*.py=32:*.rb=32:*.hs=32:*.php=32:*.htm=32:*.html=32:*.shtml=32:*.erb=32:*.haml=32:*.xml=32:*.rdf=32:*.css=32:*.sass=32:*.scss=32:*.less=32:*.js=32:*.coffee=32:*.man=32:*.0=32:*.1=32:*.2=32:*.3=32:*.4=32:*.5=32:*.6=32:*.7=32:*.8=32:*.9=32:*.l=32:*.n=32:*.p=32:*.pod=32:*.tex=32:*.go=32:*.sql=32:*.csv=32:*.bmp=33:*.cgm=33:*.dl=33:*.dvi=33:*.emf=33:*.eps=33:*.gif=33:*.jpeg=33:*.jpg=33:*.JPG=33:*.mng=33:*.pbm=33:*.pcx=33:*.pdf=33:*.pgm=33:*.png=33:*.PNG=33:*.ppm=33:*.pps=33:*.ppsx=33:*.ps=33:*.svg=33:*.svgz=33:*.tga=33:*.tif=33:*.tiff=33:*.xbm=33:*.xcf=33:*.xpm=33:*.xwd=33:*.xwd=33:*.yuv=33:*.aac=33:*.au=33:*.flac=33:*.m4a=33:*.mid=33:*.midi=33:*.mka=33:*.mp3=33:*.mpa=33:*.mpeg=33:*.mpg=33:*.ogg=33:*.opus=33:*.ra=33:*.wav=33:*.anx=33:*.asf=33:*.avi=33:*.axv=33:*.flc=33:*.fli=33:*.flv=33:*.gl=33:*.m2v=33:*.m4v=33:*.mkv=33:*.mov=33:*.MOV=33:*.mp4=33:*.mp4v=33:*.mpeg=33:*.mpg=33:*.nuv=33:*.ogm=33:*.ogv=33:*.ogx=33:*.qt=33:*.rm=33:*.rmvb=33:*.swf=33:*.vob=33:*.webm=33:*.wmv=33:*.doc=31:*.docx=31:*.rtf=31:*.odt=31:*.dot=31:*.dotx=31:*.ott=31:*.xls=31:*.xlsx=31:*.ods=31:*.ots=31:*.ppt=31:*.pptx=31:*.odp=31:*.otp=31:*.fla=31:*.psd=31:*.7z=1;35:*.apk=1;35:*.arj=1;35:*.bin=1;35:*.bz=1;35:*.bz2=1;35:*.cab=1;35:*.deb=1;35:*.dmg=1;35:*.gem=1;35:*.gz=1;35:*.iso=1;35:*.jar=1;35:*.msi=1;35:*.rar=1;35:*.rpm=1;35:*.tar=1;35:*.tbz=1;35:*.tbz2=1;35:*.tgz=1;35:*.tx=1;35:*.war=1;35:*.xpi=1;35:*.xz=1;35:*.z=1;35:*.Z=1;35:*.zip=1;35:*.ANSI-30-black=30:*.ANSI-01;30-brblack=01;30:*.ANSI-31-red=31:*.ANSI-01;31-brred=01;31:*.ANSI-32-green=32:*.ANSI-01;32-brgreen=01;32:*.ANSI-33-yellow=33:*.ANSI-01;33-bryellow=01;33:*.ANSI-34-blue=34:*.ANSI-01;34-brblue=01;34:*.ANSI-35-magenta=35:*.ANSI-01;35-brmagenta=01;35:*.ANSI-36-cyan=36:*.ANSI-01;36-brcyan=01;36:*.ANSI-37-white=37:*.ANSI-01;37-brwhite=01;37:*.log=01;32:*~=01;32:*#=01;32:*.bak=01;33:*.BAK=01;33:*.old=01;33:*.OLD=01;33:*.org_archive=01;33:*.off=01;33:*.OFF=01;33:*.dist=01;33:*.DIST=01;33:*.orig=01;33:*.ORIG=01;33:*.swp=01;33:*.swo=01;33:*,v=01;33:*.gpg=34:*.gpg=34:*.pgp=34:*.asc=34:*.3des=34:*.aes=34:*.enc=34:*.sqlite=34
  • GruvboxDark

    gruvbox dark
    1.10.5.4.6 -- gruvbox dark
  • Solarized

    Solazied
    1.10.5.4.7 -- Solazied
  • Ciapre

    Ciapre
    1.10.5.4.8 -- Ciapre
    Ciapre hotkey window
    1.10.5.4.9 -- Ciapre hotkey window
  • Hivacruz

    Hivacruz
    1.10.5.4.10 -- Hivacruz
    Hivacruz hotkey window
    1.10.5.4.11 -- Hivacruz hotkey window
  • Ryuuko

    Ryuuko
    1.10.5.4.12 -- Ryuuko
  • Relaxed

    Relaxed
    1.10.5.4.13 -- Relaxed
  • SeaShells

    Sea Shells
    1.10.5.4.14 -- Sea Shells
  • Seafoam Pastel

    Seafoam Pastel
    1.10.5.4.15 -- Seafoam Pastel
  • N0tch2k

    N0tch2k
    1.10.5.4.16 -- N0tch2k
  • Red Planet

    Red Planet
    1.10.5.4.17 -- Red Planet
  • SoftServer

    SoftServer
    1.10.5.4.18 -- SoftServer
  • Neutron

    Neutron
    1.10.5.4.19 -- Neutron
  • Blazer

    Blazer
    1.10.5.4.20 -- Blazer
  • Chester

    Chester
    1.10.5.4.21 -- Chester
  • Mirage

    Mirage
    1.10.5.4.22 -- Mirage
  • Jubi

    Jubi
    1.10.5.4.23 -- Jubi
  • Parasio Dark

    Parasio Dark
    1.10.5.4.24 -- Parasio Dark
  • ubuntu

    ubuntu
    1.10.5.4.25 -- ubuntu
    ubuntu hotkey
    1.10.5.4.26 -- ubuntu hotkey
Copyright © marslo 2020-2024 all right reserved,powered by GitbookLast Modified: 2024-11-06 21:50:32

results matching ""

    No results matching ""