😂How to add man and zip to "git bash" nén zip, tar, extract zip (ok)
https://stackoverflow.com/questions/38782928/how-to-add-man-and-zip-to-git-bash-installation-on-windows
Last updated
https://stackoverflow.com/questions/38782928/how-to-add-man-and-zip-to-git-bash-installation-on-windows
Last updated
Giải nén dùng bên này
Cách nén file bằng lệnh zip xem cài đặt 7-zip bên dưới để có thể sử dụng zip
https://www.7-zip.org/download.html
Sử dụng lệnh sau ok
Ask QuestionAsked 6 years, 7 months agoModified 1 month agoViewed 128k times115
I am using git bash
on Windows - that is git
for Windows via the integrated bash
. Apparently it uses the MINGW
/MSYS
underpinning. (Update from @VonC: It now uses msys2 since msysgit is obsolete since Q4 2015.)
So there are already a lot of MSYS
tools installed - from awk
to zcat
. However I miss the man
command and zip
to compress multiple files into a zip file (unzip
exists!).
Where from can I install them? I do not want to install another copy of the MINGW
system! Any way just to add some pre-compiled tools to the git bash
installation?
Sorted by: Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first) 80
Here's another, slightly different, set of instructions to install zip
for git bash
on windows:
Download zip-3.0-bin.zip
In the zipped file, in the bin
folder, find the file zip.exe
.
Extract the file zip.exe
to your mingw64
bin folder (for me: C:\Program Files\Git\mingw64\bin
)
Download bzip2-1.0.5-bin.zip
In the zipped file, in the bin
folder, find the file bzip2.dll
Extract bzip2.dll
to your mingw64\bin
folder (same folder as above: C:\Program Files\Git\mingw64\bin
)
5This worked like magic - beyond me why it requires the bzip2.dll file though. – Jeremy Ninnes Jan 21, 2021 at 1:35
This worked! Be sure to copy bzip2.dll
and not bzip2.zip
like I tried which didn't work. – duyn9uyen Mar 18, 2021 at 18:21
Thanks for this quick tip. I recently filled up the system disk trying to install large packages and sysadmin went postal on me. I needed a small backdoor way to get stuff done today, and this was just the ticket. – J B Jun 2, 2021 at 14:55
2022 this still works for a fellow Windows addict. many thanks. – HackerMan0 Oct 9, 2022 at 15:57
7-zip can be added to gitbash
as follows:
Install 7-zip on windows.
add 7-zip folder (C:\Program Files\7-Zip
) to PATH
On gitbash
exp: export PATH=$PATH:"C:\Program Files\7-Zip"
(temporary)
On Windows, adding PATH
like image below (permanent)
duplicate a copy of 7z.exe
to be zip.exe
reopen gitbash
again. done!
This way, it works on my laptop.
If you skip step 3. you still can call zip command as 7z
instead of zip
Conclusion: Gitbash
is running base on windows Path
, I think you can run any command that you have added to your Windows PATH
.
5This worked for me, but didn't find the need for step 3, I used the 7z
command instead. Example: 7z a -r zipped_filename.zip *
– martti d Apr 8, 2019 at 3:34
@linuxeasy I have never done that before as I remember. – nokieng Aug 5, 2019 at 2:10
1Thanks @nokieng. Step 3 was what I was looking for my specific need of installing Sdkman on windows. – Dexter Jun 9, 2020 at 10:09
great.. this was a simple, easy and effective trick that not only worked just fine but saved a lot of time:) Thank you. I was in the same situation and now good to go with the sdkman installation. – itsraghz Aug 26, 2020 at 17:09
1This worked for me saved me having to install zip on gitbash which for some inexplicable reason doesn't have a package manager – SystemsInCode Dec 12, 2020 at 14:36
2016: The zip
command can be installed from GoW (Gnu On Windows). man
is not provided (too big).
It is to note, however, that if you only want to add the zip
command from GoW, still the whole GoW system has to be downloaded and installed. Then you can delete the other commands from the bin
directory, however make sure to keep the needed dlls in the directory.
Update 2021: tar/zip are by default installed on Windows 10. 7-zip based solutions are available below.
Thanks for the clarification about msys2
. – halloleo Aug 9, 2016 at 3:52
Not sure about installing GoW - this would replicate most of the already existng comands. So maybe it is better to start again with msys2 itself and then add git
, zip
and man
to it... – halloleo Aug 9, 2016 at 3:58
You can extract from how only the zip.exe you need. – VonC Aug 9, 2016 at 4:12
I have a controlled laptop and can't install things into the typical directories. I can put "zip" in my path, but what about the DLLs? – tggagne Feb 1, 2017 at 17:28
1@AsGoodAsItGets I agree. I have edited this (old) answer to say as much. – VonC Jul 15, 2021 at 13:43
git-archive
, is prepared without any installation, can create zip-archive.
Following script may be usable: zip.sh foo.zip target_file_or_dir
1For cp
commands: prefer the use of the -a
option instead of the -r
option. "Everyone" uses the -r
option while "everyone" wants the -a
behavior... – syme Sep 5, 2019 at 15:36
I am so glad to share my experience on this issue that I haven't known for two years since the first day I played with Groovy. My method needs to have git
for Windows installed in Windows OS.
These steps are for installing 7z
command-line utility, which behaves a bit differently from zip
:
Download and install 7-Zip from its official website. By default, it is installed under the directory /c/Program Files/7-Zip
in Windows 10 as my case.
Run git Bash under Administrator privilege and navigate to the directory /c/Program Files/Git/mingw64/bin
, you can run the command ln -s "/c/Program Files/7-Zip/7z.exe" 7z.exe
I am pretty sure it could help you a lot. Trust me!
the bad thing is that 7zip does not support all cmd switches like -j
– Fritz Aug 30, 2020 at 11:37
On Windows, you can use tar instead of zip.
which is same as,
no need to install any external zip tool.
2Super Idea, Very Clever. This works. – Sriharsha Kalluru Feb 16, 2022 at 15:00
Nope. This does not produce a valid zip file in Windows. It produces a tar.gz file. – sboisse Oct 6, 2022 at 21:05
Since this was a question about git bash, the proper command would be tar.exe -a -c -f output.zip myfile.txt
Windows delivers BSD tar which is able to create ZIP files. Git Bash provides GNU tar, which can't do the same. – Christian Nov 15, 2022 at 17:15
I use choco
as my Windows Package Manager.
I install 7zip with choco
using PowerShell
(you must be admin to use Choco)
Open another gitbash
Terminal and locate the 7z.exe
executable
Do a straight copy of 7z.exe
to zip.exe
and voila
1why rename 7z to zip. 7z has different command line usage from zip. – Phani Rithvij Jan 10 at 0:28
You can mimic a small subset of man behavior in the shell by mapping man <command>
to <command> --help | less
Unfortunately, on my machine bash aliases won't add flags to positional arguments, it will try to run the flag as a command and fail (alias man="$1 --help"
doesn't work).
And a function called man()
is not allowed!
Luckily a combination of bash functions and aliases can achieve this mapping. Put the code below in your ~/.bashrc (create one if it is not there). Don't forget to source ~/.bashrc
.
It doesn't get you the full man page, but if all you're looking for is basic info on a command and its flags, this might be all you need.
Interesting alternative. +1. Although <command> --help
is often a small subset of an actual man <command>
content – VonC Aug 9, 2017 at 20:55
Creative thinking! :-) My question though was not about the man
tool alone. And I guess the zip
functionality is harder to emulate with bash functions & aliases. ;-) – halloleo Aug 10, 2017 at 3:58
You can install individual GNU tools from http://gnuwin32.sourceforge.net/packages.html such as zip
.
Then add "/c/Program Files (x86)/GnuWin32/bin"
to PATH
in your startup script like .profile
, .bash_profile
, .bashrc
, etc.
Here are the steps you can follow.
Go to the following link https://sourceforge.net/projects/gnuwin32/files/
Find out whatever command you are missing Here I need zip and bzip2 for zip command. Because zip command relies on bzip2.dll to run. Otherwise you will get error “error while loading shared libraries: ?: cannot open shared object file: No such file or directory”.
Unzip the downloaded files Here I am downloading “zip-3.0-bin.zip” for “zip.exe” and “bzip2-1.0.5-bin.zip” for “bzip2.dll” in the bin folder. /bin/.exe
Copy the command exe file into git-bash folder Here I am copying “zip.exe” and “bzip2.dll” to \Git\usr\bin.
Reference Link https://ranxing.wordpress.com/2016/12/13/add-zip-into-git-bash-on-windows/
ln -s /mingw64/bin/ziptool.exe /usr/bin/zip
ln: failed to create symbolic link '/usr/bin/zip': No such file or directory
with Git bash 2.37.2.windows.2 – Christian Nov 15, 2022 at 17:19
steps to install SDKMAN on windows
Run Windows Terminal in Admin rights. open git bash inside. (Ctrl + Shift + 4)
After you can install Java like this.
Done ! :)
In msys2, I restored the functionality of git help <command>
by installing man-db:
For zip functionality, I also use git archive
(similar to yukihane's answer).
Here's yet another 7-Zip option that I didn't notice:
Create a script named zip:
Reference 7z specifying the add command followed by the args:
Finally make it executable
This helped to make a ytt build script happy.
Though this question as been answered quite thoroughly in regards to man
there is one alternative to zipping that has not been highlighted here yet. @Zartc brought to my attention that there is a zip compression utility built-in: ziptool
. In trying to use it however I found out it is no where near a drop-in replacement and you need to specify each individual file and folder. So I dug into the docs and experimented until I had a bash-function that can do all the heavy lifting and can be used very similar to a basic zip -qrf name *
compression call:
You can then for example zip the contents of the current directory by calling it like this:
It's a great idea. However, I get "Git/mingw64/bin/ziptool.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory" on my machine – Mikaël Mayer Jun 1, 2021 at 6:31
@MikaëlMayer This seems to run without issues on several systems here, so it might be a local problem. Maybe this helps? github.com/msys2/MINGW-packages/issues/4588 – Leon S. Jun 1, 2021 at 13:26
If you are willing to install CygWin also, you can add the CygWin path to your GitBash path, and if zip is there, it will work. e.g. add
to your .bashrc
; NOTE: I would put it at the end of the path as shown, not the beginning.
Since CygWin has a UI-based installer, it's easy to add or remove applications like zip or man.
You can figure out the windows paths of each by saying
in each respective shell.
Well, the whole reason why I went down the GitBash/MSYS path was to avoid the installer driven approach of Cygwin. - If I could install Cygwin via zip files or similar (staying away from in-installer downloads) this were my first choice! – halloleo Mar 2, 2019 at 2:29
Let me guess... With Linux, you run Slackware :^) – miles zarathustra Mar 3, 2019 at 7:46
Regarding zip
, you can use a following perl
script to pack files:
If you make it executable, name it zip
, and put it in your $PATH
, you can run it like this:
zip
archive.zip
files...
however it will not work for directories. There is no need to install anything, as perl
and all required modules are already there in the Git for Windows installation.
Regarding man
, at least for git
there is a documentation invoked like this:
git
option
--help
it will open in your default browser.
Here is my experience, I cant run and exe or .msi files in my laptop. so downloaded filed from https://github.com/bmatzelle/gow/wiki > go to download Now and Downloaded Source Code (Zip) and unzipped this file in a folder and updated path variable with folder name. This worked out for me.
If you want to zip files without needing to install any additional tools on Windows, in a way that works both on git bash
and on other *nix systems, you might be able to use perl.
Per Josip Medved's blog, the following script creates an .epub (which is a zip file), and includes a filter for stripping src/
from the files added to the zip:
Interesting to know, but IMHO a how-to about "using language xy to create zip files" is not really an answer to how to install zip and man commands on Windows, particularly when there are quite a few other 'closer' answers... – halloleo Jul 12, 2022 at 1:24
copy zip.exe and bzip2.dll from C:\Program Files (x86)\GnuWin32\bin to C:\Program Files\Git\mingw64\bin
reopen git-bash
Solutions for me were just to install zip on my terminal(bash):
1The question is about Git bash on Windows. There is no apt package manager in this environment. – Christian
ShareImprove this questionFollowedited Sep 10, 2021 at 20:20i_want_more_edits13166 bronze badgesasked Aug 5, 2016 at 6:51halloleo8,6821313 gold badges5858 silver badges107107 bronze badgesAdd a comment
ShareImprove this answerFollowedited Jan 7, 2022 at 18:51Mickverm8677 bronze badgesanswered Apr 18, 2019 at 15:49NSjonas10.2k88 gold badges6060 silver badges9292 bronze badges
ShareImprove this answerFollowedited Sep 9, 2021 at 15:41i_want_more_edits13166 bronze badgesanswered Jan 22, 2019 at 4:39nokieng1,7421919 silver badges2323 bronze badges
ShareImprove this answerFollowedited Jul 15, 2021 at 13:42answered Aug 5, 2016 at 7:39VonC1.2m508508 gold badges42704270 silver badges50955095 bronze badges
ShareImprove this answerFollowedited Sep 2, 2021 at 12:16sakra60.5k1515 gold badges167167 silver badges148148 bronze badgesanswered Jul 13, 2018 at 0:59DEWA Kazuyuki - 出羽和之2,3051414 silver badges5454 bronze badges
ShareImprove this answerFollowedited Jul 29, 2019 at 15:52Erik Humphrey34355 silver badges1818 bronze badgesanswered Mar 14, 2018 at 18:32Tung1,52944 gold badges1515 silver badges3232 bronze badges
ShareImprove this answerFollowanswered Feb 7, 2022 at 18:13Vikram Sapate87199 silver badges1414 bronze badges
ShareImprove this answerFollowanswered May 2, 2020 at 22:31setrar10322 silver badges55 bronze badges
ShareImprove this answerFollowedited Aug 9, 2017 at 20:56answered Aug 9, 2017 at 17:51Dylan Kirkby1,4271111 silver badges1919 bronze badges
ShareImprove this answerFollowanswered Mar 19, 2018 at 4:49wisbucky31.2k1010 gold badges140140 silver badges9898 bronze badgesAdd a comment4
ShareImprove this answerFollowanswered Apr 18, 2018 at 18:37sagecoder10155 bronze badgesAdd a comment3
ShareImprove this answerFollowanswered Feb 3, 2021 at 14:19Zartc14466 bronze badges
ShareImprove this answerFollowedited Apr 8, 2022 at 7:01answered Feb 8, 2022 at 14:26STEEL8,34099 gold badges6767 silver badges8787 bronze badgesAdd a comment2
ShareImprove this answerFollowanswered Oct 31, 2019 at 18:06Sheldon Campbell2122 bronze badgesAdd a comment2
ShareImprove this answerFollowanswered Sep 20, 2020 at 5:30bvj3,2443131 silver badges2929 bronze badgesAdd a comment2
ShareImprove this answerFollowanswered Feb 15, 2021 at 16:23Leon S.3,27711 gold badge1818 silver badges1515 bronze badges
ShareImprove this answerFollowanswered Mar 1, 2019 at 19:11miles zarathustra19122 silver badges55 bronze badges
ShareImprove this answerFollowedited Feb 14, 2019 at 14:39answered Jan 30, 2019 at 18:15mik3,43533 gold badges2121 silver badges2929 bronze badgesAdd a comment0
ShareImprove this answerFollowanswered Feb 2, 2021 at 6:44Ravi G2122 bronze badgesAdd a comment0
ShareImprove this answerFollowanswered Jul 11, 2022 at 19:58Marc Durdin1,65522 gold badges2020 silver badges2727 bronze badges
ShareImprove this answerFollowanswered Jan 27 at 6:26jiaqi zhu1Add a comment-3
ShareImprove this answerFollowedited Jun 24, 2022 at 22:27answered Jun 24, 2022 at 22:14eldinT52611 gold badge55 silver badges1010 bronze badges