{"id":21905059,"url":"https://github.com/kenjyco/base","last_synced_at":"2025-04-15T23:21:16.274Z","repository":{"id":145905186,"uuid":"247206402","full_name":"kenjyco/base","owner":"kenjyco","description":"Shell functions and scripts to configure systems, explore open source projects, and allow maximum productivity when developing in the CLI.","archived":false,"fork":false,"pushed_at":"2024-11-23T22:58:59.000Z","size":360,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-23T23:25:45.149Z","etag":null,"topics":["bash","conditionally-defined-shell-functions","debian","fedora","macos","minimal-install","shell-scripts","ubuntu","zsh"],"latest_commit_sha":null,"homepage":"","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/kenjyco.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":"2020-03-14T03:44:45.000Z","updated_at":"2024-11-23T22:59:02.000Z","dependencies_parsed_at":"2024-06-05T11:48:36.337Z","dependency_job_id":"2025d387-8f07-4c97-bf14-cb18def965bf","html_url":"https://github.com/kenjyco/base","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenjyco%2Fbase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenjyco%2Fbase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenjyco%2Fbase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenjyco%2Fbase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kenjyco","download_url":"https://codeload.github.com/kenjyco/base/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226949023,"owners_count":17707984,"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","conditionally-defined-shell-functions","debian","fedora","macos","minimal-install","shell-scripts","ubuntu","zsh"],"created_at":"2024-11-28T16:28:14.393Z","updated_at":"2024-11-28T16:28:15.086Z","avatar_url":"https://github.com/kenjyco.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"base\n====\n\n- Jump to [Usage section](https://github.com/kenjyco/base/blob/master/README.md#usage)\n  below for examples\n\nUse `base` as an **easy way** to install the minimum essential libs/programs for\nopen-source exploration and development. Works for Linux (Debian and Fedora\nbased distros for now with more distros coming), Mac (includes installing\nhomebrew), and Windows (requires Windows Subsystem for Linux 2 to be setup\nalready with a Linux distro installed).\n\n- [Setup Linux Mint and Tips](https://github.com/kenjyco/kenjyco/blob/master/setup-linux-mint-and-tips.md)\n- [Setup Mac and Tips](https://github.com/kenjyco/kenjyco/blob/master/setup-mac-and-tips.md)\n- [Setup Windows and Tips](https://github.com/kenjyco/kenjyco/blob/master/setup-windows-10-and-tips.md)\n\n# Install\n\n### If `git` is available\n\n#### Clone the base repo\n\n```\ngit clone https://github.com/kenjyco/base ~/repos/base\n```\n\n#### Move into the cloned repo\n\n```\ncd ~/repos/base\n```\n\n#### Source the install.sh file\n\n```\nsource ./install.sh extras\n```\n\n\u003e Note: If you are in an interactive **fish shell**, do not source `install.sh`,\n\u003e but invoke either `bash ./install.sh` OR `zsh ./install.sh`\n\nThe `install.sh` script behaves differently if any of the following strings are\npassed in:\n\n- **`clean`**: ensures the git/docker completion files match installed versions\n  (if packages were updated)\n- **`extras`**: also installs non-essential, but light-weight CLI packages like\n  `vim`, `tmux`, `tree`, `ncdu`, `glances`, `nnn` and more\n- **`gui`**: also installs some light-weight GUI packges for Linux (including\n  xorg-server, `awesome`, `rxvt-unicode`, `feh`, `scrot`, etc) or Mac (iTerm, vlc)\n- **`all`**: clean extras gui\n\t- this will also create the `~/tools-py` directory, with a virtual\n      environment containing a number of python packages (like `asciinema`,\n      `awscli`, `flake8`, `twine`, `httpie`, `grip`, and more)\n    - you can run `tools-py-install-all` later if desired\n\n### Interactive prompts during installation\n\n#### Update completions\n\nAfter the selected system packages are installed, you will be prompted if you\nwant to update completions for bash. Type `y` and hit enter.\n\n```\nUpdate completions for bash? [y/n] y\n```\n\n\u003e This ensures that tab-completion works and will also fetch the bash or zsh\n\u003e completion file for your version of `git` (and `docker` if installed).\n\u003e\n\u003e You can call `get-completions` again if you ever install newer versions of\n\u003e `git` or `docker` in the future.\n\n#### Select your prompt style\n\nAfter that, you will be prompted to select your prompt style from five basic\noptions. Type the desired number and hit enter.\n\n```\nSelect prompt mode\n1) system-default   3) terse            5) minimal-plus\n2) verbose          4) minimal\n?# 5\n```\n\n\u003e The **verbose** prompt includes the username, hostname, full path to the\n\u003e current working directory, and a newline for better visual separation. The\n\u003e **terse** prompt has the hostname and the name of the current working\n\u003e directory with no newline. The **minimal** prompt only has a single character,\n\u003e a newline, and no color. The **minimal-plus** prompt (my favorite) has a\n\u003e single character, a newline, and the name of the current working directory.\n\u003e\n\u003e All custom prompts except 'minimal' have color and will show your current git\n\u003e branch if you are in a git repo.\n\u003e\n\u003e If you are unsure, select option 2 (verbose). You can change your selection by\n\u003e running the `prompt-select-mode` command later.\n\u003e\n\u003e You can also change the prompt style for your current terminal by using any of\n\u003e the following: `prompt-system-default`, `prompt-verbose`, `prompt-terse`,\n\u003e `prompt-minimal`, or `prompt-minimal-plus`.\n\n#### Clone and setup dotfiles\n\nFinally, if you don't have your own custom `.vimrc` or `.tmux.conf`, you will be\nprompted to clone and setup dotfiles. (Experienced users typically have their\nown preferences stored in these files).\n\n```\nNo local config found for vim or tmux.\nClone and setup dotfiles? [y/n] n\n```\n\n\u003e The dotfiles repo will be cloned next to the base repo, and a number of\n\u003e symbolic links will be created in your HOME directory, pointing to files in\n\u003e the dotfiles repo (`.ctags`, `.editrc`, `.gitconfig`, `.inputrc`, `.ipython`,\n\u003e `.psqlrc`, `.tmux.conf`, `.tmux`, `.vim`, `.vimrc`, `.vimrc`, `.xinitrc`, and\n\u003e `.Xdefaults`).\n\u003e\n\u003e You can use `dotfiles-install` later on if desired. See:\n\u003e \u003chttps://github.com/kenjyco/dotfiles\u003e\n\n# About\n\nWhen you source the `install.sh` script, your package manager will install\nor update some packages, three symbolic links will be created in your\n`$HOME` directory, and `~/commands.sh` will be \"auto-sourced\" at the end\n(i.e. if using bash/zsh, the \"shell functions\" defined in `~/commands.sh` will\nbe \"loaded\" into your shell whenever you start a session, allowing you to call\nany of those funcitons by name while using the terminal).\n\n- `~/bin-base` -\u003e /path/to/base/bin\n    - directory containing some executable shell scripts\n- `~/commands.fish` -\u003e /path/to/base/commands.fish\n    - file that can/should be sourced if using an interactive fish session\n    - *only a small subset of what is available in commands.sh*\n- `~/commands.sh` -\u003e /path/to/base/commands.sh\n    - file that can/should be sourced if using an interactive bash/zsh session\n    - contains definitions of **many useful shell functions and aliases**\n\nWhen you source `~/commands.sh` or `~/commands.fish` (directly or indirectly):\n\n- GNU versions of `find`, `grep`, `sort`, and `xargs` will be used if they are\n  installed on a Mac (over the default BSD versions)\n- shell completions will be enabled for your installed versions of `git` and\n  `docker`\n- **vi keybindings will be used for navigating/editing the command line**\n    - *i.e. hit \u003cEsc\u003e to enter \"command mode\" (to issue vi commands) and\n      `i`/`I`/`a`/`A` to get back to \"insert mode\"*\n    - effective to reinforce/practice vi motions for early learners\n- any shell functions defined inside can be called\n    - *Note: most functions/aliases are conditionally defined, meaning that\n      no assumptions are made about what programs are available to your\n      system...*\n        - if a shell func or alias makes use of a particular program and you\n          don't have that program installed on your system, the func or alias\n          will not be defined\n        - if a shell func or alias requires using `sudo` (and you're not in\n          the sudo/admin group, or the root user), the func or alias will not\n          be defined\n- the `~/bin-base` directory will be added to your `$PATH` environment variable,\n  allowing you to invoke any of the scripts in there\n\n# Update\n\n```\nbase-update\n```\n\n\u003e That command will `cd` to wherever you initially cloned this base repository,\n\u003e pull in the latest changes via `git`, and re-source the install.sh file.\n\n# Usage\n\n\u003e Note: these shell functions and scripts are named for easy tab-complete\n\u003e (typing part of the command's name, then hitting the `\u003cTab\u003e` key to fill in\n\u003e the rest, or `\u003cTab\u003e` twice to show all the commands that match what was typed\n\u003e so far).\n\n### Working with `repos-` commands\n\n\u003e These are all scripts in \u003chttps://github.com/kenjyco/base/tree/master/bin\u003e\n\n```\n% repos-list            # List all git repos under current directory (or abs path of current repo)\n\n% repos-dirs            # List directories that have git repos in them (with counts)\n\n% repos-fetch           # Perform a git fetch on repos found and output updates only\n\n% repos-update          # Stash changes and git pull --rebase (then git stash pop)\n\n% repos-status          # Show repos with any changes, untracked files, or stashes\n                        # Also show if branch is behind or ahead of remote\n\n% repos-last-commit-dates   # Show last commit date of each repo\n\n% repos-files           # List files in current directory (recursive) by commit date\n                        # Arg passed in to filter list of files matched/returned\n\n% repos-commits         # Show latest commits on all repos under current directory (args passed to git log)\n                        # (i.e \"--since 2.days\", \"--grep alias -5\", etc)\n\n% repos-show-stashes    # Show any stashes saved on all repos under current directory\n\n% repos-branches        # Show latest 10 remote branches and all local branches\n                        # Arg passed in to filter list of branch names matched\n\n% repos-branches-all    # Show all remote branches and all local branches\n                        # Arg passed in to filter list of branch names matched\n\n% repos-branches-short  # Show locally checked out branch for all repos under current directory\n\n\n% repos-last-tag        # List last tag of git repos that have tags\n\n% repos-last-tag-message    # List last tag and message of git repos that have tags\n\n% repos-tags            # List all tags of git repos that have tags\n\n% repos-diffs           # List all git repos under current directory and show diff since last git add\n\n% repos-commits-not-on-master   # Show commits on an origin branch not on origin/master\n\n% repos-commits-since-last-tag  # Show commits since the last tag for each repo\n\n% repos-delete-local-branches   # Show diffs for local branches and prompt for deletion\n\n% repos-do              # Repeats given command inside each repo found\n                        # (i.e. repos-do 'grep -A 15 requires setup.py \u0026\u0026 cat requirements.txt')\n\n% repos-do-output       # Same as repos-do, but only lists repos when command has output\n```\n\n### The `findit` command\n\n```\n% findit --help\nUsage: findit [dir] [options]\n\n  Wrapper to the find command\n\nOptions:\n\n  --depth number              maxdepth to search for files\n  --type character            regular (f)ile, (d)irectory, symbolic (l)ink, (s)ocket, (b)lock special\n  --pattern string            comma-separated list of filename patterns\n  --ipattern string           comma-separated list of filename patterns (case insensitive)\n  --complex string            raw options passed directly to 'find'\n  --exclude_dirs string       comma-separated list of directories/patterns to exclude\n  --iexclude_dirs string      comma-separated list of directories/patterns to exclude (case insensitive)\n  --exclude_exts string       comma-separated list of extensions to exclude\n  --iexclude_exts string      comma-separated list of extensions to exclude (case insensitive)\n  --exclude string            comma-separated list of filename patterns to exclude\n  --iexclude string           comma-separated list of filename patterns to exclude (case insensitive)\n  --exts string               comma-separated list of extensions to include\n  --iexts string              comma-separated list of extensions to include (case insensitive)\n  --sizes string              comma-separated list of sizes, prefixed with +/- and unit of k M or G (i.e. +2G)\n  --empty                     only match files that are empty\n  --not_empty                 only match files that are not empty\n  --months number             only match files modified in a number of months\n  --weeks number              only match files modified in a number of weeks\n  --days number               only match files modified in a number of days\n  --hours number              only match files modified in a number of hours\n  --minutes number            only match files modified in a number of minutes\n  --pipe command              pipe files to a SINGLE command\n  --pipesort command          pipe sorted files to a SINGLE command\n  --zero                      print matching filenames delimited by null char (-print0)... to pipe to 'xargs -0 -I {}' manually\n  --stamp                     prepend timestamps to output\n  --help                      show this message and exit\n\nExamples:\n\n  findit --exts \"md\" --weeks 1 --stamp\n  findit --exts \"md\" --weeks 1 --pipesort \"cp -av {} /tmp/stuff\"\n  findit ~ --exts \"md, txt\" --exclude_dirs \"venv, node_modules, Library\" --months 2 --depth 3\n  findit --pattern \".*.sw[po]\" --pipe \"ls -gothr\"\n  findit --exts \"mp4, mkv\" --pipesort \"vlc --fullscreen\"\n  findit --exts \"jpg, jpeg, png, gif\" --pipe \"du -sch\"\n  findit --exts \"xml\" --pipesort \"grep --color {{[^}]*}}\"\n  findit --depth 3 --exts \"log\" --not_empty --pipesort \"wc -l\"\n  findit --complex \"-iname '*.log' -type f ! -size 0\"\n  findit --complex \"-iname '*.log' -type f -empty -delete\"\n  findit --pattern \"node_modules\" --type d\n  findit --sizes \"+1G\" --pipesort \"du -sh\"\n  findit --depth 4 --sizes \"+1M, -10M\" --exclude_dirs \".cache\" --pipesort \"du -sh\"\n  findit --type d --exclude_dirs \".git\" --depth 2\n  findit --exclude_dirs \"node_modules, .git, venv, build, alembic, __pycache__, .pytest_cache\" --exclude_exts \"json, yml, xml, txt, md\" --pipe \"wc -l\"\n  findit --exclude_dirs \"venv, env\" --exclude_exts \"js, json, java, map, htm, html, pyc\" --pattern \"test*\" --pipe \"grep assert\" | grep -E \"(==|!=)\"\n  findit --pattern \"__init__.py\" --exclude_dirs \"venv\" --not_empty --pipesort \"wc -l\" | sort -n\n  findit --depth 4 --type d --exclude_dirs \".git, *.egg-info, venv\" --not_empty --pipesort \"du -sh {}\" | sort -h\n  findit --exclude_dirs \"venv\" --pattern \"settings.ini\" --zero | xargs -0 -I {} sh -c \"echo \\\"\\n\\n\\n==================\\n{}\\\"; cat {}\"\n```\n\n### The `grepit` commands\n\n- **`grepit`**: recursively search current directory for matching lines (`-HnI\n  --color -R` in use, as well as `--exclude` for many file extensions` and\n  `--exclude-dir` for many directories); any options received get passed to `grep`\n    - `-i pattern` to ignore case in search\n    - `-E '(pattern1|pattern2|..)'` to match multiple patterns\n    - `-B 1 -A 2 pattern` to show context lines (1 before match and 2 after)\n    - `\\bpattern\\b` to only match when pattern is surrounded by a \"word\n      boundary\" character (i.e. don't match a sub-string in a longer word)\n- **`grepit-count`**: use `grepit` to show how many times pattern is matched in\n  files (sorted by count and not showing zero matches)\n- **`grepit-no-docs`**: use `grepit`, but also ignore txt/md/rst files\n- **`grepit-no-docs-no-tests`**: also ignore test dirs\n- **`grepit-py`**: similar to `grepit`, but only include .py files and ignore\n  common directories\n- **`grepit-py-no-tests`**: similar to `grepit-py`, but also exclude .py files\n  in test directories\n\n### The `grep` commands\n\n- **`grep-object-info`**: recursively find usage of methods/attributes on the\n  specified object, ordered by the number of occurrences\n- **`grep-object-info-no-tests`**: same as grep-object-info, but does not search\n  in test directories\n- **`grep-history`**: search history files in `$HOME` for pattern\n    - example: grep-history \"git log [^-]\"\n- **`grep-history-exact`**: search history files in `$HOME` for pattern\n- **`grep-history-comments`**: use `grep-history` to find entries that start\n  with `#`\n\n### The `example-usage` commands\n\n\u003e If you called `install.sh` to do setup and the `~/.base_path` file exists,\n\u003e several shell functions prefixed with `example-usage--` will be available.\n\u003e They all go to wherever the base repo is cloned, use `grepit` to find actual\n\u003e examples and usage patterns for certain things, then go back to wherever you\n\u003e were.\n\n- **`example-usage--date-format-strings`**: show examples of some \"format\n  strings\" passed to the `date` command\n    - \u003chttps://man7.org/linux/man-pages/man1/date.1.html\u003e (jump to \"FORMATS\"\n      section\n    - \u003chttps://strftime.org\u003e\n- **`example-usage--substitutions-perl`**: show examples of using `perl` and\n  \"regular expressions\" to modify output (that was piped to perl)\n- **`example-usage--substitutions-sed`**: show examples of using `sed` and\n  \"regular expressions\" to modify output (that was piped to sed)\n- **`example-usage--test-regex-match`**: show examples of using `=~` in a shell\n  conditional test to see if some text matches a \"regular expression\"\n- **`example-usage--grepit`**: show examples of using `grepit`\n- **`example-usage--findit`**: show examples of using `findit`\n- **`example-usage--iterate-repos`**: show examples of iterating over repos\n  (mostly using `repos-list` with `xargs`)\n- **`example-usage--user-input-bash`**: show examples of using `read -p` to get\n  user input when using bash (i.e. `[[ -n \"$BASH_VERSION\" ]]`)\n- **`example-usage--user-input-zsh`**: show examples of using `vared -p` to get\n  user input when using zsh (i.e. `[[ -n \"$ZSH_VERSION\" ]]`)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkenjyco%2Fbase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkenjyco%2Fbase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkenjyco%2Fbase/lists"}