{"id":13897737,"url":"https://github.com/LucHermitte/Bash-scripts","last_synced_at":"2025-07-17T14:32:42.274Z","repository":{"id":3884846,"uuid":"4971848","full_name":"LucHermitte/Bash-scripts","owner":"LucHermitte","description":"Miscellaneous scripts to enhance bash (prompt, adding directories to variables, ...)","archived":false,"fork":false,"pushed_at":"2025-01-31T13:12:24.000Z","size":48,"stargazers_count":24,"open_issues_count":3,"forks_count":89,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-31T14:23:23.713Z","etag":null,"topics":["bash","cygwin","inputrc"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LucHermitte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-07-10T09:32:45.000Z","updated_at":"2025-01-31T13:12:28.000Z","dependencies_parsed_at":"2024-11-25T09:03:48.162Z","dependency_job_id":null,"html_url":"https://github.com/LucHermitte/Bash-scripts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LucHermitte/Bash-scripts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucHermitte%2FBash-scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucHermitte%2FBash-scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucHermitte%2FBash-scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucHermitte%2FBash-scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LucHermitte","download_url":"https://codeload.github.com/LucHermitte/Bash-scripts/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucHermitte%2FBash-scripts/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265616857,"owners_count":23798909,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","cygwin","inputrc"],"created_at":"2024-08-06T18:03:50.642Z","updated_at":"2025-07-17T14:32:41.998Z","avatar_url":"https://github.com/LucHermitte.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"Bash-scripts\n============\n\nMiscellaneous scripts to enhance bash (prompt, adding directories to variables, ...)\n\nTable of Contents\n* [Scripts](#scripts)\n  * [push.bashrc](#pushbashrc)\n  * [ssh.bashrc](#sshbashrc)\n  * [munge.bashrc](#mungebashrc)\n  * [cyg-wrapper.sh](#cyg-wrappersh)\n* [Installation](#installation)\n\n## Scripts\n\n### push.bashrc\n\nThis script provides a few helpers on top of pushd/popd/dirs functions.\nFor a description of how these commands are used, see for instance\n\u003chttp://www.softpanorama.org/Scripting/Shellorama/pushd_and_popd.shtml\u003e\n\nThis script overrides the default presentation of the three commands, and\nprovides the following aliases:\n\n* `d`/`dirs` now displays one pushed directory per line, preceded by the\n  directory index within the stack. (this is close to `\\dirs -v`).\n  When given an argument, `dirs` will display only the pushed directories that\n  match the regex.\n\n* `p`/`pushd` and `popd` will display `dirs` result after each directories\n  stack modification.\n\n* `p1` to `p9` are aliases on `pushd +1` to `pushd +9`\n\n* `g`/`go` searches for a pushed directory in the stack that matches all the\n  regexes received as parameters. If several directories match, the list of\n  matching directories is displayed, and the current directory is left\n  unchanged.\n\nOther similar aliases can be found over internet, see for instance:\n \u003chttp://blogs.sun.com/nico/entry/ksh_functions_galore\u003e.\n\n\nOther commands aimed at storing bash configuration (directories pushed and\nenvironment variables) are also provided:\n\n* `save_conf \u003cconf-id\u003e` saves the current directories pushed, `env` contents\n  and history in the files `$SHELL_CONF/\u003cconf-id\u003e.dirs`,\n  `$SHELL_CONF/\u003cconf-id\u003e.env`, and `$SHELL_CONF/\u003cconf-id\u003e.hist`.\n\n* `load_conf \u003cconf-id\u003e` restores the configuration saved with the previous\n  command. Actually the environment is not restored. However, the differences\n  between the current and the saved environment are displayed.  \n  Bash autocompletion is defined for `load_conf`.\n\nThe default value for `$SHELL_CONF` is `$HOME/.config/bash`\n\n### ssh.bashrc\n\nThis script is meant to be sourced from the `~/.bashrc`. It will ask for the\npass-phrase, once, and then it will remember it for later.\n\n### munge.bashrc\n\nThis script is meant to be sourced from the `~/.bashrc` to help help filling\npaths into variables like `$PATH`. The main objective is to avoid duplicates in\nthe path variables.\n\nFor instance, with\n```bash\nmunge PATH \"$HOME/bin\"\nmunge MANPATH \"$HOME/man\"\n```\nyou won't end up with `$HOME/bin` twice, or more, into your `$PATH`.\n\n`munge VARIABLE new-path` will add the new path **before** the other ones.\n\n`munge VARIABLE new-path after` will add the new path **after** the other ones.\n\nThe script also defines\n* `change_or_munge VARIABLE old-path new-path`  to replace a path\n* `remove_path VARIABLE paths-to-remove...`  to remove a list of paths\n* `clean_path VARIABLE` to remove duplicates\n* `munge_std_variables new-path` to define in one go `$PATH`, `$LD_LIBRARY_PATH`, `$MANPATH`, `$INFOPATH`, `$PKG_CONFIG_PATH` depending in what is found in the new directory\n\nAll four commands come with autocompletion for bash.\n\nAlso, after a\n\n```bash\nmunge FOOPATH /some/path\nmunge FOOPATH /other/path\n```\n\nA `FOOPATH` alias will be automatically defined, it'll print `$FOOPATH` value,\nwith each path on a new line. This means that if you use `munge` on `PATH`,\n`LD_LIBRARY_PATH`, or `MANPATH`, etc, eponym aliases will be defined!\n\n### nm_and_grep.sh\n\nThis small script encapsulates `nm` and `grep`. Typical uses are:\n```bash\n# Find all libraries having the searched symbol:\nfind . \\( -name '*.so' -o -name '*.a' \\) -exec nm_n_grep.sh {} symbol \\; -print\n\n# Find in which library used in an executable defines the searched symbol:\nldd executable | sed 's#.*=\u003e[      ]*##' | xargs -I {}  ~1/nm_n_grep.sh -b {} symbol\n```\n\n\n### cyg-wrapper.sh\n#####Running a native win32 application from cygwin/bash\n\nThe cygwin *NIX emulation layer completly changes the way the paths are\nmanaged. All the cygwin hierarchy appears under the `/`: new root directory as\non unices. Unfortunately, MsWindows native tools (i.e. not using the cygwin\nlayer) can't understand paths expressed in the UNIX way.  In order to convert\n*NIX (i.e. cygwin)-paths into plain MsWindows-paths, we can use: `cygpath -w`.\n\nBut, Cygwin also permits many nice things like symbolic links -- try `man ln`.\nUnfortunately, *cygpath* seems (at this time) unable to follow these links and\nto return the exact MsWindows-path to the linked-files.\n\nMoreover, I had many headaches with the management of spaces on MsWindows 9x\nseries when using command line invocation of native win32 tools.\n\nSo here is `cyg-wrapper.sh`, a shell script that fixes all these problems. It\npermits to launch native win32 applications from command-line (or even from\nMutt) with any kind of pathnames passed as parameters.\n\n\n#####Usage\nTo get help on the way to use cyg-wrapper, try `cyg-wrapper.sh --help | less`.\n\nIn my `~/.profile`, I usually have the following to run native win32 gvim from\ncygwin:\n\n```bash\n ### Vim\n ## Little trick for LaTeX-Suite:\n # If one of the parameters is a (La)TeX file, then we declare the\n # servername to be �LATEX�.\n gvim() {\n    opt=''\n    if [ `expr \"$*\" : '.*tex\\\u003e'` -gt 0 ] ; then\n        opt='--servername LATEX '\n    fi\n    cyg-wrapper.sh \"C:/Progra~1/Edition/vim/vim74/gvim.exe\" --binary-opt=-c,--cmd,-T,-t,--servername,--remote-send,--remote-expr --cyg-verbose --fork=2 $opt \"$@\"\n }\n ### Some other windows programs\n alias explore='cyg-wrapper.sh \"explorer\" --slashed-opt'\n alias mplayer='cyg-wrapper.sh \"c:/Progra~1/Window~1/mplayer2.exe\"'\n```\n\nAs a consequence, we can type this.\n\n```bash\n    gvim /etc/profile -c /PS1 -c \"echo 'correctly opened'\"\n # or even:\n    cd ~/tmp ; ln -s ~/bin/cyg-wrapper.sh\n    gvim -d http://hermitte.free.fr/cygwin/cyg-wrapper.sh cyg-wrapper.sh\n\n    explorer -e\n    explorer \"$vim\"\n    explorer http://hermitte.free.fr/\n```\n\n#####Requirements\n* *cyg*Utils to run and more precisely `realpath`.\n\n## Installation\n\nIn order to install all these scripts into `$HOME/bin`, just run\n```bash\n./install.sh\n```\n\nOr, if you'd rather install them elsewhere like `/share/stuff/bin`, type\n```bash\n./install.sh /share/stuff\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLucHermitte%2FBash-scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLucHermitte%2FBash-scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLucHermitte%2FBash-scripts/lists"}