Colored files in Windows terminal via Cygwin? - windows-7

I have Cygwin installed on my Win7 laptop and by editing my Windows path variable I'm able to get Linux commands in my Windows command terminal. My Question is there a way to get colored file output to transfer to the Windows command line?
Through Cygwin I obviously just alias my .bashrc file, but from Googling and checking Cygwin FAQs I can't find any way to reference that file in a Windows prompt. Although 'ls --color=auto' does work, is there a way to alias this through the Windows command line in any way?

#Al G - Yes. I already can use commands by editing my PATH to include the Cygwin /bin directory but I was wondering if there was a way to carryover aliases. However I was able to answer my own question:
Using naitve Windows aliasing via DOSKEY I can create an alias for ls to auto color file types like this:
DOSKEY ls=ls --color=auto

Put the alias in the .bash_profile (create if not present), not in .bashrc.
In my case:
alias ls='ls --color=auto -la'

Related

fzf not workign with git bash (installation via scoop)

I installed fzf via scoop on windows 10 but unfortunately it works well on cmd but impossible to make it work on git bash. I found a similar topic here: Is it possible to use fzf (command line fuzzy finder) with windows 10 git-bash?
but i don't understand these commands at all.
I checked the shims( the Windows command-line installer.) files of fzf and I have this as path
path = "C:\Users\<user name>\scoop\apps\fzf\current\fzf.exe"
fzf works fine on cmd but I need the bash interpreter. It's very annoying, anyone have an idea?
When I write
`fzf --help`
the command is recognized on git bash, it means that the command works but it returns nothing.
For Windows 10 (git bash) - try winpty fzf
You can also set an alias in .bashrc:
alias fzf="winpty fzf"

alias in .bashrc using Mac OSX: command works on the command line but in an alias it doesn't work

I realise there are a few questions similar to this but nothing that fully addresses the issue I'm getting.
I'm writing a few alias' for terminal commands I often use.
$ cd ~/Documents/blah/blah/blah
This works as a terminal command, but when I try to turn this into an alias:
alias pie='cd ~/Documents/blah/blah/blah'
This doesn't work, -bash: cd: Documents/blah/blah/blah: No such file or directory
I'm storing the alias in .bashrc in my home directory. I'm using Mac OSX.
Anyone know why it would work as a straight command but not an alias?
Similarly, I use a vagrant machine, and I'd like the chain together two commands: one to ssh to vagrant and the other to open the shell:
alias vshell='vagrant ssh && python manage.py shell
But this doesn't seem possible, it only ever executes the first command, maybe because this takes a little longer to complete?
Thanks

Executing MSYS2 Emacs from Windows command line or shortcut

I recently installed MSYS2 with Emacs (64-bit) and am currently calling that Emacs from a Windows shortcut. It works fine, exactly like if I had downloaded the Emacs executable for Windows and unzipped it somewhere. Which is to say, it picks up all of my Windows environment variables and such.
For various reasons, I would prefer to run Emacs from an MSYS2 bash shell and use the environment variables in that shell. As it stands, I can open an MSYS2 MINGW64 shell, type emacs on the command line, and everything works the way I want it to.
Now I would like to package the whole thing up into either a one-liner I can stuff into to a Windows shortcut or a script I can call from a Windows shortcut. With the help of this post, I came up with the following:
C:\msys64\bin\mintty.exe /bin/env MSYSTEM=MINGW64 /bin/bash -l -c /mingw64/bin/emacs
This successfully opens Emacs, but fails to load the .bashrc file that I source in .bash_profile in the usual manner:
if [ -f "${HOME}/.bashrc" ] ; then
source "${HOME}/.bashrc"
fi
I define a function in .bashrc that I call in .bash_profile, so this is kind of important. It did not take much effort to realize that the problem is that HOME is not defined, so .bashrc is simply not found. However, if I define HOME like so:
C:\msys64\bin\mintty.exe /bin/env HOME=/home/alanhr MSYSTEM=MINGW64 /bin/bash -l -c /mingw64/bin/emacs
I get exactly the same result: .bashrc is not found and my function is not executed. Here's where it gets weird. If I simply leave off the call to emacs like so:
C:\msys64\bin\mintty.exe /bin/env HOME=/home/alanhr MSYSTEM=MINGW64 /bin/bash -l
I get a bash shell where .bashrc has been loaded correctly and my function is correctly executed. I can type emacs on the command line and have it function exactly as I want it to.
This feels like a classic case of missing something that is right under my nose, but I have read the bash man page to no avail. Does anyone have any idea how I can make this work?
It is the -i option to load .bashrc. The following works for me:
C:\msys64\usr\bin\mintty.exe -w hide /bin/env MSYSTEM=MINGW64 /bin/bash -l -i -c /mingw64/bin/emacs

New Windows 7 git install, missing commands in bins, e.g. alias for git bash

Just installed git on my Windows 7 laptop and desktop and it seems that some standard Unix commands are missing in the setup. I'm new to Git and not that great with Windows stuff.
I found out the issue by trying to configure the git bash using a .bashrc by adding a simple alias thus:
alias ls 'ls -F'
When the .bashrc is run (and it's getting executed when the shell starts), I get this message:
$ alias ls 'ls -F'
bash: alias: ls: not found
bash: alias: ls -F: not found
Upon closer examination of the bin directories (/bin, /usr/bin, i.e. C:\Program Files\Git\bin and C:\Program Files\Git\usr\bin, respectively) there is no alias or alias.exe.
I'm assuming this has something to do with Unix commands re-created into windows executable and not some branch of a path that I'm missing. I've checked on the path and cannot find some hidden bin directory.
I've seen several postings on installing Cygwin on it's own and I can do this but before launching into a protracted fix for both my laptop and desktop I'd like to know if I'm missing something or my git initial install is bad or if there's a package that I should be adding -- would appreciate any assistance.
The correct syntax would be:
alias ls='ls -F'
alias is a bash builtin command, so you won't find an alias.exe anywhere in the git distribution.

Cygwin Terminal and zsh strange characters used in username

Hi I've recently installed zsh using cygwin on my Windows machince but when I type zsh to start this I get the following:
GG#GG-PC ~
$ zsh
\[\e]0;\w\a\]\n\[\e[32m\]\u#\h \[\e[33m\]\w\[\e[0m\]\n\$
On my mac I am using iTerm2 and this is so much easier to setup on here. Also I am having trouble in setting up the aliases and this is becauses its not setup properly in terms of config file where I can set this up in a separate file.
Any ideas how I can resolve?
It looks like zsh is inheriting the value of PS1 from the previous shell. The PS1 environment variable sets the shell prompt, and zsh used a different format for prompt substitutions than other shells. Try entering the following command after you start zsh:
PS1=$'%{\e]0;%d\a%}\n%F{green}%n#%m %F{yellow}%d%f\n%# '
If that works, add that line to your ~/.zshrc file.
That's also probably a good place to put your aliases.
There might be an issue because you launch zsh from bash actually and not cygwin.
One thing you can do is to launch zsh as the starting shell of mintty (the window that wraps your shell)
Create a shortcut with this inside:
c:\<cygwin-folder>\bin\mintty.exe -i /Cygwin-Terminal.ico /usr/bin/zsh --login -
Yo need to update .zshrc with your required theme and then
source .zshrc

Resources