Making Things Easier in Cygwin

  Рет қаралды 7,235

Michael Chu

Michael Chu

Күн бұрын

Пікірлер: 31
@mehdicharife2335
@mehdicharife2335 3 жыл бұрын
Thanks man, that was very useful.
@mgc9002
@mgc9002 3 жыл бұрын
You're welcome
@mgc9002
@mgc9002 8 жыл бұрын
I just discovered a neat feature of the mintty terminal: if you drag & drop a file/folder from Windows Explorer into the terminal, the full *NIX-style pathname gets dumped in. The best part? It will automatically enclose the pathname in quote marks if there are spaces!
@mgc9002
@mgc9002 8 жыл бұрын
My recent video solely about mintty features: kzbin.info/www/bejne/j3WydnivhNBkmMU
@smyrtgyz
@smyrtgyz 6 жыл бұрын
Thank you for your time!
@rgriff29
@rgriff29 8 жыл бұрын
thank you for the great tutorial
@mgc9002
@mgc9002 8 жыл бұрын
You are most welcome! You may also enjoy the "mintty" video, which demonstrates some very nifty features built into the terminal: kzbin.info/www/bejne/j3WydnivhNBkmMU
@k.l.dyellow6463
@k.l.dyellow6463 6 жыл бұрын
very nice. thanks Mike!!
@mgc9002
@mgc9002 6 жыл бұрын
+kang li you're welcome! I do plan on recording some more videos this year; hope they will be useful too
@k.l.dyellow6463
@k.l.dyellow6463 6 жыл бұрын
Michael Chu please! I also watched your other recordings as well. I setup both cgwin and as well as run a Ubuntu bash on Windows Pro. One thing would be nice to share how is your bashrc, profile....I am currently trying to setup ls_color to get my shell in colors. Thanks
@mgc9002
@mgc9002 6 жыл бұрын
Not much to show on that, I'm afraid. My .bashrc has basically just the items discussed in this video, plus a handful of other settings, e.g. "set -o vi" which lets you use vi-style keyboard strokes to edit the command line. Colour is something I've been playing with in shell scripts, but I've been happy with what the shell displays by default so haven't tweaked that at all.
@mgc9002
@mgc9002 6 жыл бұрын
@kang li, Perhaps a bit too late, but I found this old article on customizing the Mintty colours. Didn't follow through with the instructions (since I'm happy with my setup), but you may be interested: randomartifacts.blogspot.com/2012/10/a-proper-cygwin-environment.html
@billma12345
@billma12345 8 жыл бұрын
i was wondering the same question about bashrc vs bash_profile haha. seems like you'd only use bash_profile if you want something executed right when you login and then use bashrc when you're already in the terminal
@mgc9002
@mgc9002 8 жыл бұрын
I think you're right! I just added some dummy "echo" commands into both, and it looks like both are run when you open a new terminal (regardless of how many you already have open), and only the bashrc runs when you start a bash shell within an existing session. Can't think of when I would really need that, since I rarely start shells within shells ...
@Lowzenza4
@Lowzenza4 6 жыл бұрын
How do you get your cygwin shell to open with your working directory prined out? I used export PS1="\w $ " but my prompt is always ~ $ only. How does everyone have their profile name show up?
@mgc9002
@mgc9002 6 жыл бұрын
@Lowzenza Short answer for you: add \u to get your username too: export PS1="\u \w $ " Extended answer: the Bash shell lets you customize your prompt quite a bit. For example, to show name and directory in different colours, try this: export PS1='\[\e[32m\]\u \[\e[33m\]\w\[\e[0m\] \$ ' The 32 before \u (username) makes it green; the 33 before \w (working directory) makes it yellow; and the 0 near the end resets the terminal to black. If you want other colours, you can check the first 2 columns in this Wikipedia table: en.wikipedia.org/wiki/ANSI_escape_code#3.2F4_bit If you are interested in seeing all the available codes to customize the prompt, check the 'bash' manual page under the heading "PROMPTING". Here's a command you can copy+paste into your terminal to jump right to that section: man --pager='less -p ^PROMPTING' bash I prefer to start my PS1 with so there is a blank line before the prompt. e.g. export PS1=' \[\e[32m\]\u \[\e[33m\]\w\[\e[0m\] \$ '
@houssemgargouri6173
@houssemgargouri6173 7 жыл бұрын
thanks but i have problem in the command ipconfig and ifconfig it said bash : command not found any solution ?
@mgc9002
@mgc9002 7 жыл бұрын
+Gargouri Houssem ipconfig should be available as a Windows command, but ifconfig is not normally available so it is normal that you cannot find it. It sounds like your $PATH variable is not set up properly. Try echoing both $PATH and $ORIGINAL_PATH variables. Both should show paths starting with /cygdrive/ ... Here is a reference link for you about how the path is set: cygwin.com/faq/faq.html#faq.using.path
@houssemgargouri6173
@houssemgargouri6173 7 жыл бұрын
it worked with this path : export PATH=$PATH:"/bin:/cygdrive/c/Windows/system32" thx
@awakekat
@awakekat 8 жыл бұрын
Just wondering how to autoload the .bashrc file into cygwin when it starts. Thanks. I am a mac person and it just works there. Learning to setup windows for my students.
@mgc9002
@mgc9002 8 жыл бұрын
+Katherine Wakefield Hi Katherine. The .bashrc file will automatically execute when you open a Cygwin terminal. Or, were you asking how to customize the .bashrc for everyone that uses the computer with Cygwin? If so, I believe you can make edits to the "/etc/skel/.bashrc" file; new users get a copy of this file when their home directory is created.
@awakekat
@awakekat 8 жыл бұрын
Um well for me opening my Cygwin it does not load my .bashrc file. I have several aliases such as "D" = Desktop and it doesn't go there. it also does not under stand "ls"
@mgc9002
@mgc9002 8 жыл бұрын
I think your Cygwin shortcut isn't configured properly. Try right-clicking on the Cygwin shortcut and checking the value of the "Target" field. It should read something like this: C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico - The hyphen at the end is key: it runs bash as a login shell, meaning .bashrc will be loaded. Please give that a try. If it doesn't work, let me know what is showing up in the Target field for your Cygwin shortcut. For your reference, I took screenshots of what I'm seeing on my computer - hope it helps: goo.gl/photos/LoMGeYnsPrP131Jd8
@awakekat
@awakekat 8 жыл бұрын
The target looks exactly like yours - thanks for the photo. :(
@mgc9002
@mgc9002 8 жыл бұрын
+Katherine Wakefield It could be that the installation somehow got messed up, and a fresh reinstall will fix things. (At work, my colleagues and I have had to resort to this from time to time.) Cygwin does not have a real uninstall process, so to try this, just rename/relocate the existing C:\cygwin64 folder, then run the installer again. Another thing you could try is to start the bash shell directly. Try the following command in the Windows command prompt (or from the Windows "Run" prompt): C:\cygwin64\bin\bash.exe --login -i
@1sbollap
@1sbollap 8 жыл бұрын
thank you for the video. cygstart filename.txt is opening a file in notepad. how can i change that to open in notepad++
@mgc9002
@mgc9002 8 жыл бұрын
+1sbollap cygstart uses the same program that Windows would use to open a file. So, to make it use Notepad++, you must set Notepad++ as the default file handler for .txt files
@mgc9002
@mgc9002 8 жыл бұрын
+1sbollap cygstart uses the same program that Windows would use to open a file. So, to make it use Notepad++, you must set Notepad++ as the default file handler for .txt files
@1sbollap
@1sbollap 8 жыл бұрын
Thank you very much. I went into Notepadd++ > Settings > Prefs > File Associations and added .txt to Registered exts and it worked