Skip to content

Commit

Permalink
merge: main
Browse files Browse the repository at this point in the history
  • Loading branch information
keenahn committed Jul 28, 2023
2 parents abd896a + 4188b22 commit 85bc2da
Show file tree
Hide file tree
Showing 76 changed files with 674 additions and 334 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ plugins/shell-proxy/ @septs
plugins/universalarchive/ @Konfekt
plugins/wp-cli/ @joshmedeski
plugins/zoxide/ @ajeetdsouza
plugins/starship/ @axieax
plugins/dbt/ @msempere
55 changes: 55 additions & 0 deletions .github/workflows/installer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Test and Deploy installer
on:
workflow_dispatch: {}
push:
paths:
- tools/install.sh
- .github/workflows/installer
- .github/workflows/installer.yml

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: false

permissions:
contents: read # to checkout

jobs:
test:
name: Test installer
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
steps:
- name: Set up git repository
uses: actions/checkout@v3
- name: Install zsh
if: runner.os == 'Linux'
run: sudo apt-get update; sudo apt-get install zsh
- name: Test installer
run: sh ./tools/install.sh

deploy:
name: Deploy installer in install.ohmyz.sh
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
environment: vercel
needs:
- test
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Vercel CLI
run: npm install -g vercel
- name: Setup project and deploy
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
run: |
cp tools/install.sh .github/workflows/installer/install.sh
cd .github/workflows/installer
vc link --yes -t ${{ secrets.VERCEL_TOKEN }}
vc deploy --prod -t ${{ secrets.VERCEL_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/installer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
install.sh
2 changes: 2 additions & 0 deletions .github/workflows/installer/.vercelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/*
!/install.sh
14 changes: 14 additions & 0 deletions .github/workflows/installer/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"headers": [
{
"source": "/((?!favicon.ico).*)",
"headers": [{ "key": "Content-Type", "value": "text/plain" }]
}
],
"rewrites": [
{
"source": "/((?!favicon.ico|install.sh).*)",
"destination": "/install.sh"
}
]
}
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ jobs:
- name: Install zsh
if: runner.os == 'Linux'
run: sudo apt-get update; sudo apt-get install zsh
- name: Test installer
run: sh ./tools/install.sh
- name: Check syntax
run: |
for file in ./oh-my-zsh.sh \
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi
- [Manual Installation](#manual-installation)
- [Installation Problems](#installation-problems)
- [Custom Plugins and Themes](#custom-plugins-and-themes)
- [Enable GNU ls in macOS and freeBSD systems](#enable-gnu-ls)
- [Skip aliases](#skip-aliases)
- [Getting Updates](#getting-updates)
- [Updates verbosity](#updates-verbosity)
Expand Down Expand Up @@ -278,6 +279,20 @@ If you have many functions that go well together, you can put them as a `XYZ.plu

If you would like to override the functionality of a plugin distributed with Oh My Zsh, create a plugin of the same name in the `custom/plugins/` directory and it will be loaded instead of the one in `plugins/`.

### Enable GNU ls in macOS and freeBSD systems

<a name="enable-gnu-ls"></a>

The default behaviour in Oh My Zsh is to use BSD `ls` in macOS and freeBSD systems. If GNU `ls` is installed
(as `gls` command), you can choose to use it instead. To do it, you can use zstyle-based config before
sourcing `oh-my-zsh.sh`:

```zsh
zstyle ':omz:lib:theme-and-appearance' gnu-ls yes
```

_Note: this is not compatible with `DISABLE_LS_COLORS=true`_

### Skip aliases

<a name="remove-directories-aliases"></a>
Expand Down
18 changes: 10 additions & 8 deletions custom/example.zsh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# You can put files here to add functionality separated per file, which
# will be ignored by git.
# Files on the custom/ directory will be automatically loaded by the init
# script, in alphabetical order.

# For example: add yourself some shortcuts to projects you often work on.
#
# Put files in this folder to add your own custom functionality.
# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization
#
# Files in the custom/ directory will be:
# - loaded automatically by the init script, in alphabetical order
# - loaded last, after all built-ins in the lib/ directory, to override them
# - ignored by git by default
#
# Example: add custom/shortcuts.zsh for shortcuts to your local projects
#
# brainstormr=~/Projects/development/planetargon/brainstormr
# cd $brainstormr
#
3 changes: 3 additions & 0 deletions custom/plugins/example/example.plugin.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Add your own custom plugins in the custom/plugins directory. Plugins placed
# here will override ones with the same name in the main plugins directory.
# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-plugins
2 changes: 2 additions & 0 deletions custom/themes/example.zsh-theme
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Put your custom themes in this folder.
# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-themes
#
# Example:

PROMPT="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%~ %{$reset_color%}%% "
2 changes: 1 addition & 1 deletion lib/cli.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function omz {

# Subcommand functions start with _ so that they don't
# appear as completion entries when looking for `omz`
(( $+functions[_omz::$command] )) || {
(( ${+functions[_omz::$command]} )) || {
_omz::help
return 1
}
Expand Down
2 changes: 1 addition & 1 deletion lib/functions.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function zsh_stats() {
}

function uninstall_oh_my_zsh() {
env ZSH="$ZSH" sh "$ZSH/tools/uninstall.sh"
command env ZSH="$ZSH" sh "$ZSH/tools/uninstall.sh"
}

function upgrade_oh_my_zsh() {
Expand Down
9 changes: 6 additions & 3 deletions lib/termsupport.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ fi
#
# As of May 2021 mlterm, PuTTY, rxvt, screen, termux & xterm simply ignore the unknown OSC.

# Don't define the function if we're inside Emacs
if [[ -n "$INSIDE_EMACS" ]]; then
# Don't define the function if we're inside Emacs or in an SSH session (#11696)
if [[ -n "$INSIDE_EMACS" || -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then
return
fi

Expand Down Expand Up @@ -150,8 +150,11 @@ function omz_termsupport_cwd {
URL_HOST="$(omz_urlencode -P $HOST)" || return 1
URL_PATH="$(omz_urlencode -P $PWD)" || return 1

# Konsole errors if the HOST is provided
[[ -z "$KONSOLE_VERSION" ]] || URL_HOST=""

# common control sequence (OSC 7) to set current host and path
printf "\e]7;%s\a" "file://${URL_HOST}${URL_PATH}"
printf "\e]7;file://%s%s\e\\" "${URL_HOST}" "${URL_PATH}"
}

# Use a precmd hook instead of a chpwd hook to avoid contaminating output
Expand Down
36 changes: 17 additions & 19 deletions lib/theme-and-appearance.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,25 @@ if command diff --color /dev/null{,} &>/dev/null; then
}
fi


# Don't set ls coloring if disabled
[[ "$DISABLE_LS_COLORS" != true ]] || return 0

# Default coloring for BSD-based ls
export LSCOLORS="Gxfxcxdxbxegedabagacad"

# Default coloring for GNU-based ls
if [[ -z "$LS_COLORS" ]]; then
# Define LS_COLORS via dircolors if available. Otherwise, set a default
# equivalent to LSCOLORS (generated via https://geoff.greer.fm/lscolors)
if (( $+commands[dircolors] )); then
[[ -f "$HOME/.dircolors" ]] \
&& source <(dircolors -b "$HOME/.dircolors") \
|| source <(dircolors -b)
else
export LS_COLORS="di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43"
fi
fi

function test-ls-args {
local cmd="$1" # ls, gls, colorls, ...
local args="${@[2,-1]}" # arguments except the first one
Expand All @@ -50,7 +65,7 @@ case "$OSTYPE" in
test-ls-args ls -G && alias ls='ls -G'
# Only use GNU ls if installed and there are user defaults for $LS_COLORS,
# as the default coloring scheme is not very pretty
[[ -n "$LS_COLORS" || -f "$HOME/.dircolors" ]] \
zstyle -t ':omz:lib:theme-and-appearance' gnu-ls \
&& test-ls-args gls --color \
&& alias ls='gls --color=tty'
;;
Expand All @@ -64,20 +79,3 @@ case "$OSTYPE" in
esac

unfunction test-ls-args


# Default coloring for BSD-based ls
export LSCOLORS="Gxfxcxdxbxegedabagacad"

# Default coloring for GNU-based ls
if [[ -z "$LS_COLORS" ]]; then
# Define LS_COLORS via dircolors if available. Otherwise, set a default
# equivalent to LSCOLORS (generated via https://geoff.greer.fm/lscolors)
if (( $+commands[dircolors] )); then
[[ -f "$HOME/.dircolors" ]] \
&& source <(dircolors -b "$HOME/.dircolors") \
|| source <(dircolors -b)
else
export LS_COLORS="di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43"
fi
fi
20 changes: 13 additions & 7 deletions oh-my-zsh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ _omz_source() {
zstyle -T ":omz:${context}" aliases || disable_aliases=1

# Back up alias names prior to sourcing
local -a aliases_pre galiases_pre
local -A aliases_pre galiases_pre
if (( disable_aliases )); then
aliases_pre=("${(@k)aliases}")
galiases_pre=("${(@k)galiases}")
aliases_pre=("${(@kv)aliases}")
galiases_pre=("${(@kv)galiases}")
fi

# Source file from $ZSH_CUSTOM if it exists, otherwise from $ZSH
Expand All @@ -174,10 +174,16 @@ _omz_source() {

# Unset all aliases that don't appear in the backed up list of aliases
if (( disable_aliases )); then
local -a disabled
# ${var:|array} gets the list of items in var not in array
disabled=("${(@k)aliases:|aliases_pre}" "${(@k)galiases:|galiases_pre}")
(( $#disabled == 0 )) || unalias "${(@)disabled}"
if (( #aliases_pre )); then
aliases=("${(@kv)aliases_pre}")
else
(( #aliases )) && unalias "${(@k)aliases}"
fi
if (( #galiases_pre )); then
galiases=("${(@kv)galiases_pre}")
else
(( #galiases )) && unalias "${(@k)galiases}"
fi
fi
}

Expand Down
10 changes: 5 additions & 5 deletions plugins/aliases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ Requirements: Python needs to be installed.

## Usage

- `acs`: show all aliases by group
- `als`: show all aliases by group

- `acs -h/--help`: print help mesage
- `als -h/--help`: print help mesage

- `acs <keyword(s)>`: filter and highlight aliases by `<keyword>`
- `als <keyword(s)>`: filter and highlight aliases by `<keyword>`

- `acs -g <group>/--group <group>`: show only aliases for group `<group>`. Multiple uses of the flag show all groups
- `als -g <group>/--group <group>`: show only aliases for group `<group>`. Multiple uses of the flag show all groups

- `acs --groups`: show only group names
- `als --groups`: show only group names

![screenshot](https://cloud.githubusercontent.com/assets/3602957/11581913/cb54fb8a-9a82-11e5-846b-5a67f67ad9ad.png)
2 changes: 1 addition & 1 deletion plugins/aliases/aliases.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
0="${${(M)0:#/*}:-$PWD/$0}"

eval '
function acs(){
function als(){
(( $+commands[python3] )) || {
echo "[error] No python executable detected"
return
Expand Down
2 changes: 1 addition & 1 deletion plugins/aliases/cheatsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def pretty_print(cheatsheet, wfilter, group_list=None, groups_only=False):
pretty_print_group(key, [ alias for alias in aliases if alias[0].find(wfilter)>-1 or alias[1].find(wfilter)>-1], wfilter)

if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Pretty print aliases.", prog="acs")
parser = argparse.ArgumentParser(description="Pretty print aliases.", prog="als")
parser.add_argument('filter', nargs="*", metavar="<keyword>", help="search aliases matching keywords")
parser.add_argument('-g', '--group', dest="group_list", action='append', help="only print aliases in given groups")
parser.add_argument('--groups', dest='groups_only', action='store_true', help="only print alias groups")
Expand Down
1 change: 1 addition & 0 deletions plugins/archlinux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,4 @@ whether the package manager is installed, checked in the following order:
- Ybalrid (Arthur Brainville) - [email protected]
- Jeff M. Hubbard - [email protected]
- K. Harishankar(harishnkr) - [email protected]
- WH-2099 - [email protected]
32 changes: 15 additions & 17 deletions plugins/archlinux/archlinux.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,25 @@ alias pacown='pacman -Qo'
alias pacupd="sudo pacman -Sy"

function paclist() {
# Based on https://bbs.archlinux.org/viewtopic.php?id=93683
pacman -Qqe | \
xargs -I '{}' \
expac "${bold_color}% 20n ${fg_no_bold[white]}%d${reset_color}" '{}'
pacman -Qqe | xargs -I{} -P0 --no-run-if-empty pacman -Qs --color=auto "^{}\$"
}

function pacdisowned() {
local tmp db fs
tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
db=$tmp/db
fs=$tmp/fs
local tmp_dir db fs
tmp_dir=$(mktemp --directory)
db=$tmp_dir/db
fs=$tmp_dir/fs

mkdir "$tmp"
trap 'rm -rf "$tmp"' EXIT
trap "rm -rf $tmp_dir" EXIT

pacman -Qlq | sort -u > "$db"

find /bin /etc /lib /sbin /usr ! -name lost+found \
find /etc /usr ! -name lost+found \
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"

comm -23 "$fs" "$db"

rm -rf $tmp_dir
}

alias pacmanallkeys='sudo pacman-key --refresh-keys'
Expand Down Expand Up @@ -180,17 +178,17 @@ fi

# Check Arch Linux PGP Keyring before System Upgrade to prevent failure.
function upgrade() {
echo "[oh-my-zsh] Checking Arch Linux PGP Keyring"
echo ":: Checking Arch Linux PGP Keyring..."
local installedver="$(sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')"
local currentver="$(sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')"
if [ $installedver != $currentver ]; then
echo "[oh-my-zsh] Arch Linux PGP Keyring is out of date."
echo "[oh-my-zsh] Updating before full system upgrade."
sudo pacman -Syu --needed --noconfirm archlinux-keyring
echo " Arch Linux PGP Keyring is out of date."
echo " Updating before full system upgrade."
sudo pacman -Sy --needed --noconfirm archlinux-keyring
else
echo "[oh-my-zsh] Arch Linux PGP Keyring is up to date."
echo " Arch Linux PGP Keyring is up to date."
echo " Proceeding with full system upgrade."
fi
echo "[oh-mh-zsh] Proceeding with full system upgrade."
if (( $+commands[yay] )); then
yay -Syu
elif (( $+commands[trizen] )); then
Expand Down

0 comments on commit 85bc2da

Please sign in to comment.