Skip to content

Instantly share code, notes, and snippets.

@Fire-Dragon-DoL
Created July 25, 2014 18:56
Show Gist options
  • Save Fire-Dragon-DoL/141af739558e84c89604 to your computer and use it in GitHub Desktop.
Save Fire-Dragon-DoL/141af739558e84c89604 to your computer and use it in GitHub Desktop.
Cygwin inside ConsoleZ (ex Console2), use in Yakuake-like fashion and open new tab in specified path, useful with Sublime Text Terminal plugin

YaConsoleZ

Cygwin inside ConsoleZ (ex Console2), use in Yakuake-like fashion and open new tab in specified path, useful with Sublime Text Terminal plugin

Instructions

  • Install Cygwin, ConsoleZ and Autohotkey
  • Put console.xml in %appdata%\Console\console.xml, or set ConsoleZ in the same way
  • Paste a shortcut into startup folder of the autohotkey executable, so it autorun Autohotkey.ahk file, which should be put in your Documents folder
  • Make an executable of console_on_path.ahk using Convert .ahk to .exe tool, remember to customize your paths
  • BONUS! Use Terminal.sublime-settings for your terminal settings
; This must be always running in background
OpenShellIfNotRunning()
{
Opening := False
DetectHiddenWindows, on
IfWinNotExist ahk_class Console_2_Main
{
ConsolePath := "PATH\TO\Console.exe"
EnvGet UserProfile, UserProfile
Run %ConsolePath%, "-d", %UserProfile%
Opening := True
WinWaitActive ahk_class Console_2_Main
}
DetectHiddenWindows, off
Return Opening
}
ShowShell()
{
WinShow ahk_class Console_2_Main
WinActivate ahk_class Console_2_Main
ControlFocus ahk_class Console_2_Main, ahk_class Console_2_Main
}
HideShell()
{
WinHide ahk_class Console_2_Main
MouseGetPos,,, WinUMID
WinActivate ahk_id %WinUMID%
}
; Hotkey is Win + \
#\::
If (OpenShellIfNotRunning())
{
ShowShell()
}
Else
{
; If Window Visible
IfWinExist ahk_class Console_2_Main
{
HideShell()
}
Else
{
ShowShell()
}
}
Return
<?xml version="1.0"?>
<settings>
<console change_refresh="10" refresh="100" rows="23" columns="200" buffer_rows="500" buffer_columns="0" shell="" init_dir="" start_hidden="0" save_size="0" background_text_opacity="255">
<colors>
<color id="0" r="0" g="0" b="0"/>
<color id="1" r="0" g="0" b="128"/>
<color id="2" r="0" g="150" b="0"/>
<color id="3" r="0" g="150" b="150"/>
<color id="4" r="170" g="25" b="25"/>
<color id="5" r="128" g="0" b="128"/>
<color id="6" r="128" g="128" b="0"/>
<color id="7" r="192" g="192" b="192"/>
<color id="8" r="128" g="128" b="128"/>
<color id="9" r="0" g="100" b="255"/>
<color id="10" r="0" g="255" b="0"/>
<color id="11" r="0" g="255" b="255"/>
<color id="12" r="255" g="50" b="50"/>
<color id="13" r="255" g="0" b="255"/>
<color id="14" r="255" g="255" b="0"/>
<color id="15" r="255" g="255" b="255"/>
</colors>
</console>
<appearance>
<font name="Consolas" size="12" bold="0" italic="0" smoothing="2" extra_width="0" bold_intensified="0" italic_intensified="0">
<color use="0" r="0" g="0" b="0"/>
</font>
<window title="Console" icon="" use_tab_icon="1" use_console_title="0" show_cmd="1" show_cmd_tabs="1" use_tab_title="1" trim_tab_titles="20" trim_tab_titles_right="0" main_title_format="?U([%u] )?N({%u} )%m?s( - %s)" tab_title_format="%s"/>
<controls show_menu="0" show_toolbar="1" show_statusbar="1" show_tabs="1" hide_single_tab="0" show_scrollbars="1" flat_scrollbars="1" tabs_on_bottom="1" show_searchbar="1" hide_tab_icons="0"/>
<styles caption="0" resizable="0" taskbar_button="0" border="0" inside_border="2" tray_icon="1" quake_like="1" quake_animation_time="300" jumplist="0" integrated_ime="0">
<selection_color r="255" g="255" b="255"/>
</styles>
<position x="40" y="0" dock="-1" snap="-1" z_order="1" save_position="0" w="-1" h="-1" save_size="0"/>
<transparency type="1" active_alpha="235" inactive_alpha="235" r="0" g="0" b="0"/>
<fullscreen start_in_fullscreen="0" fullscreen_monitor="0"/></appearance>
<behavior>
<copy_paste copy_on_select="0" clear_on_copy="1" no_wrap="1" trim_spaces="1" copy_newline_char="0" sensitive_copy="1" eol_spaces="1" rtf="1" include_left_delimiter="0" include_right_delimiter="0" left_delimiters=" ([" right_delimiters=" )]"/>
<scroll page_scroll_rows="0"/>
<tab_highlight flashes="3" stay_highligted="1"/>
<close allow_closing_last_view="0" confirm_closing_multiple_views="0"/><focus follow_mouse="0"/><instance allow_multi="0"/><clone use_current_dir="1"/><search match_case="0" match_whole_word="0"/><runas use_credprov="1"/></behavior>
<hotkeys use_scroll_lock="1">
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="settings"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="help"/>
<hotkey ctrl="0" shift="0" alt="1" extended="0" code="115" command="exit"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="84" command="newtab1"/>
<hotkey ctrl="1" shift="1" alt="0" extended="0" code="50" command="newtab2"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="114" command="newtab3"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="115" command="newtab4"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="116" command="newtab5"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="117" command="newtab6"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="118" command="newtab7"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="119" command="newtab8"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="120" command="newtab9"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="121" command="newtab10"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="newtab11"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="newtab12"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="49" command="switchtab1"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="50" command="switchtab2"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="51" command="switchtab3"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="52" command="switchtab4"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="53" command="switchtab5"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="54" command="switchtab6"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="55" command="switchtab7"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="56" command="switchtab8"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="57" command="switchtab9"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="48" command="switchtab10"/>
<hotkey ctrl="0" shift="1" alt="0" extended="1" code="39" command="nexttab"/>
<hotkey ctrl="0" shift="1" alt="0" extended="1" code="37" command="prevtab"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="87" command="closetab"/>
<hotkey ctrl="1" shift="0" alt="0" extended="0" code="82" command="renametab"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="nextview"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="prevview"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="leftview"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="rightview"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="topview"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="bottomview"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="dechsize"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="inchsize"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="decvsize"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="incvsize"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="closeview"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="detachview"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="attach"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="splithoriz"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="splitvert"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="clone"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="fullscreen"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="zoom100"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="zoominc"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="zoomdec"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="groupall"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="ungroupall"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="grouptab"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="ungrouptab"/>
<hotkey ctrl="1" shift="1" alt="0" extended="0" code="67" command="copy"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="selectall"/>
<hotkey ctrl="1" shift="1" alt="0" extended="1" code="46" command="clear_selection"/>
<hotkey ctrl="1" shift="1" alt="0" extended="0" code="86" command="paste"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="stopscroll"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollrowup"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollrowdown"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollpageup"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollpagedown"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollcolleft"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollcolright"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollpageleft"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollpageright"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="find"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="findnext"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="findprev"/>
<hotkey ctrl="1" shift="1" alt="0" extended="0" code="112" command="dumpbuffer"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd1"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd2"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd3"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd4"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd5"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd6"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd7"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd8"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd9"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd10"/>
<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="activate" win="0"/>
</hotkeys>
<mouse>
<actions>
<action ctrl="0" shift="0" alt="0" button="1" name="copy"/>
<action ctrl="0" shift="0" alt="0" button="1" name="select"/>
<action ctrl="0" shift="0" alt="0" button="0" name="select_column"/>
<action ctrl="0" shift="0" alt="0" button="3" name="paste"/>
<action ctrl="1" shift="0" alt="0" button="1" name="drag"/>
<action ctrl="0" shift="0" alt="0" button="2" name="menu"/>
<action ctrl="0" shift="0" alt="0" button="0" name="menu2"/>
<action ctrl="0" shift="0" alt="0" button="0" name="menu3"/>
</actions>
</mouse>
<tabs>
<tab title="Bash" use_default_icon="0">
<console shell="&quot;PATH\TO\console_on_path.bat&quot;" init_dir="" run_as_user="0" user="" net_only="0" run_as_admin="0"/>
<cursor style="4" r="255" g="255" b="255"/>
<background type="0" r="0" g="0" b="0">
<image file="" relative="0" extend="0" position="0">
<tint opacity="0" r="0" g="0" b="0"/>
</image>
</background>
</tab>
<tab title="ConsoleZ" use_default_icon="0">
<console shell="" init_dir="" run_as_user="0" user="" net_only="0" run_as_admin="0"/>
<cursor style="0" r="255" g="255" b="255"/>
<background type="0" r="0" g="0" b="0">
<image file="" relative="0" extend="0" position="0">
<tint opacity="0" r="0" g="0" b="0"/>
</image>
</background>
</tab>
</tabs>
<external_commands>
</external_commands></settings>
; Make an executable for this one, is just a wrapper to ensure window is shown after opening it
#SingleInstance ignore
OpenShell()
{
ConsolePath := "PATH\TO\Console.exe"
Run %ConsolePath%, "-d", %A_WorkingDir%
}
ShowShell()
{
WinShow ahk_class Console_2_Main
WinActivate ahk_class Console_2_Main
ControlFocus ahk_class Console_2_Main, ahk_class Console_2_Main
}
OpenShell()
ShowShell()
ExitApp
PATH\TO\cygwin64\bin\bash.exe --login -c "cd \"`cygpath -u \\\"%CD%\\\"`\" ; clear; exec bash"
{
// The command to execute for the terminal, leave blank for the OS default
// On OS X the terminal can be set to iTerm.sh to execute iTerm
"terminal": "PATH\\TO\\console_on_path.exe",
// A list of default parameters to pass to the terminal, this can be
// overridden by passing the "parameters" key with a list value to the args
// dict when calling the "open_terminal" or "open_terminal_project_folder"
// commands
"parameters": [
"%CWD%"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment