CLI: Cygwin, Babun, etc

CLI: Cygwin, Babun, etc

Incredible articla: Windows Development Environment Perfect Dev Environment on Windows, the easiest way Installing web server on windows 10 – Siglar

What is what?

Get the Scoop, a Homebrew for Windows

Linux Emulators:

  • MSYS doesn’t seem to be developed anymore. It is the shell for the MinGW which is a Windows port of the GNU compiler tools, such as GCC, Make, Bash, and so on.
  • Cygwin is a large collection of GNU tools (like MinGW) but also an substantial POSIX API functionality layer. For example, you can use Unix feature such as pipes, etc. Sometimes too much of a Linux. See: Cygwin vs MSYS
  • MSYS2 is a rich environment as an evolution of the old MSYS. Package manager included is Arch Linux’s pacman. But it does have almost everything.
  • Windows Subsystem for Linux aka WSL 2 should be the future. Provide a Linux emulation layer and gives you access to real Linux distributions. It’s pretty weird and not everything works.

Terminals:

  • Clink is just cmd.exe enhancer, that provides the native Windows shell with the features of the Linux GNU Readline library from bash + small other enhancements. Clink doesn’t support Powershell.
  • ConEmu is and was for a long time the best terminal on Windows.
  • Cmder is ConEmu wrapper with integrated Clink and some visual customizations.
  • Babun is pre-configured Cygwin environment but it is discontinued as of 2019.
  • Microsoft Windows Terminal aka “WSL Terminal” should be the future, and is something like ConEmu only official.

Package Managers:

  • Scoop is easy to use and has the most of the command line tools I need. It manages the PATH so all the tools are available in native apps without any magic. See: Scoop vs Chocolatey
  • Chocolatey is package manager but at a higher level than Scoop. It’s less focused on being a shell and assumes you’re a Powershell user, which I’m not and barely understand. Useful for packages that cannot be installed with Scoop.

Current selection: MSYS2 + Cmder + Scoop Note: I don’t have mosh as it is Cygwin only (and Chrome?)

Setup

To install Scoop, in a PowerShell command console, run:

iwr -useb get.scoop.sh | iex

Install MSYS2:

scoop install msys2
msys2
# must run `msys2` as an administrator and just close the console once it finishes running all the commands 

Install Cmder:

scoop install cmder

Unify .SSH keys folder location

Be careful as you must not delete anything. If you delete private key, you will NEVER regain an access to that resource.

I’m tired of the current situation: Babun and probably any other cygwin derivate uses .SSH keys from c:\Users\<user>\.babun\cygwin\home\<user>\.ssh and the rest of the Windows ecosystem from c:/Users/<user>/.ssh. Therefore, terminal I’m using gets it from Babun, and editor I’m using (Visual Studio Code) gets it from Windows.

Immediately collect all the keys and config’s into c:/Users/<user>/.ssh folder. This will be, from now on, that ONE location for SSH keys and configs. From inside Babun (cygwin) type:

1
2
3
rm ~/.ssh -r
ln -s "/c/Users/cat $(whoami)/.ssh"  ~
chmod 600 ~/.ssh/config

Checked and everything works as expected.

Clink is sent from god

scoop install clink
clink autorun install

To retrieve the settings path and show values, type clink set

Integrate MSYS2 into Cmder


Installin MariaDB on Windows with scoop

Installing web server on windows 10 – Siglar


Environment variables I’ve removed: System:

C:\Program Files (x86)\Common Files\Oracle\Java\javapath
C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler
C:\PROGRAMDATA\ORACLE\JAVA\JAVAPATH
C:\PROGRAM FILES (X86)\COMMON FILES\INTEL\SHARED FILES\CPP\BIN\INTEL64
C:\PROGRAM FILES\DELL\DW WLAN CARD
Uninstalled: C:\PROGRAM FILES\IDM COMPUTER SOLUTIONS\ULTRAFTP
   Remove this: "C:\Program Files\IDM Computer Solutions"
   Plus Registry
C:\PROGRAM FILES (X86)\MICROSOFT EMULATOR MANAGER\1.0\
C:\PROGRAM FILES\GIT\CMD
C:\Program Files (x86)\AOMEI Backupper
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL
C:\Program Files\Intel\Intel(R) Management Engine Components\DAL
C:\WINDOWS\SYSTEM32\OPENSSH\
C:\WINDOWS\System32\OpenSSH\
%SYSTEMROOT%\System32\OpenSSH\
C:\Program Files\Intel\WiFi\bin\
C:\Program Files\Common Files\Intel\WirelessCommon\
C:\WINDOWS\SYSTEM32\WBEM
C:\WINDOWS\System32\Wbem
C:\WINDOWS\system32
C:\WINDOWS\SYSTEM32
C:\WINDOWS
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
C:\WINDOWS\SYSTEM32\WINDOWSPOWERSHELL\V1.0\
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR
C:\ProgramData\DockerDesktop\version-bin
C:\Program Files\Docker\Docker\Resources\bin

c:\bin\exoscale
C:\bin\gtools
C:\bin\php7
C:\bin\tools
C:\Users\cvladan\cvladan\.babun
C:\ProgramData\chocolatey\bin

User:

C:\Users\cvladan\go\bin
C:\Program Files\Common Files\Intel\WirelessCommon\
C:\Program Files\Intel\WiFi\bin\

Show variables:

$env:path -split ";"

But the proper way, without expanding environment names is:

System: (Get-Item -Path “HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment” ).GetValue(‘Path’, ‘’, ‘DoNotExpandEnvironmentNames’) User: (Get-Item -path “HKCU:\Environment” ).GetValue(‘Path’, ‘’, ‘DoNotExpandEnvironmentNames’)

There is Choco nice command refreshenv.

Everything in one line:

scoop install php composer

Install Git

scoop install git
scoop install openssh
# must be executed in powershell
[environment]::setenvironmentvariable('GIT_SSH', (resolve-path (scoop which ssh)), 'USER')

.env must exist or composer install won’t finish


Create a project:

composer create-project symfony/skeleton my_project_name

To check if you are in 32bit or 64bit command prompt, type the following:

Babun officialy only supports 32-bit Cygwin

echo %PROCESSOR_ARCHITECTURE%

Symfony 4 how to enable prod mode?


Install MariaDB / MySQL via command line only

Installing web server on windows 10 – Siglar

In 64bit environment, type:

scoop install mariadb 

Must start cmd with admin privileges:

mysql_install_db --port=3306 --service=MariaDB --password=mypass -o

Open port in firewall (if needed):

netsh advfirewall firewall add rule name="MySQL Port" protocol=TCP dir=in localport=3306 action=allow
# netsh advfirewall firewall add rule name="MySQL Port" protocol=TCP dir=out localport=3306 action=allow 

Install and setup everything:

mysql_install_db

sudo mysql_install_db –port=4406 –service=MariaDB –password=mypass –verbose-bootstrap

Note: “mysqld –install” and “mysqld –remove” are suggested not to use anymore as we now have mysql_install_db and service removal can be done with simple call to sc delete <service-name>.


Moving slowly to native windows shell

I’m focusing more on PowerShell vs cmd.exe as that is obvious future.

%UserProfile%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 

Powerline patched font You probably need a font better than the default on Windows for some symbols to show up. Go to Nerd Fonts Repository and download a good powerline patched font. My personal preference is Meslo Nerd Font. Install it as per the instruction in the Repository Readme.MD

scoop bucket add nerd-fonts

Just once: $ scoop bucket add nerd-fonts Install each-font: sudo scoop install “Inconsolata-NF”

See which ones are available: scoop search “-NF” https://github.com/matthewjberger/scoop-nerd-fonts/tree/master/bucket

And select MesloLGM NF in ConEmu

https://github.com/whitecolor/my-nerd-fonts

sudo scoop install DejaVuSansMono-NF DroidSansMono-NF FiraMono-NF Inconsolata-NF InconsolataGo-NF Monoid-NF Mononoki-NF RobotoMono-NF SourceCodePro-NF SpaceMono-NF UbuntuMono-NF Ubuntu-NF Tinos-NF

DejaVuSansMono-NF InconsolataGo-NF Mononoki-NF RobotoMono-NF Source Code Pro

PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command “Invoke-Expression ‘Import-Module ‘’%UserProfile%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1’’’”

PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command “Invoke-Expression ‘Import-Module ‘’%UserProfile%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1’’’” -new_console:d:C:\Projects\fairwalter.ch

Write-Host “$([char]0xE0B0) $([char]0x00B1) $([char]0xE0A0) $([char]0x27A6) $([char]0x2718) $([char]0x26A1) $([char]0x2699)”

Write-Host $([char]0x2122)

Coding fonts

Site to compare coding fonts: Dev Fonts

Stvarno lep font novi coding font: Geist Font — Vercel vercel/geist-font

Aliases in PowerShell

I have an aliases (most notable ll) in cmd.exe via clink, but in PowerShell it’s a bit different.

Import-Alias Alias.csv

Get-Alias ls

Remove stupid default aliases:

Remove-Item Alias:cat
Remove-Item Alias:cp
Remove-Item Alias:curl
Remove-Item Alias:echo
Remove-Item Alias:ls
Remove-Item Alias:man
Remove-Item Alias:mv
Remove-Item Alias:pwd
Remove-Item Alias:rm
Remove-Item Alias:rmdir
Remove-Item Alias:wget

Edit user profile:

ise $PROFILE

or host specific:

ise $PROFILE.AllUsersAllHosts

See: https://devblogs.microsoft.com/scripting/understanding-the-six-powershell-profiles/


Set-Alias -Name np -Value C:\Windows\notepad.exe

Simple aliases are easy to set,

Set-Alias ll "ls"

but passing parameters is more difficult. There is no need to set alias as function only works the same:

function ll { $a = $args; if ($args -eq "."){ $a = $pwd }; &"ls.exe" -lah --color=tty $a }
date 06. May 2020 | modified 10. Jun 2024
filename: Windows » Dev Environment » Cygwin, Babun, etc