Skip to content

Instantly share code, notes, and snippets.

@njbmartin
Last active January 9, 2023 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save njbmartin/af0445347a29ec00686713061d2d1138 to your computer and use it in GitHub Desktop.
Save njbmartin/af0445347a29ec00686713061d2d1138 to your computer and use it in GitHub Desktop.

Install the Shopify CLI and aliases

$SHELL -c "$(curl -fsSL https://gist.githubusercontent.com/njbmartin/af0445347a29ec00686713061d2d1138/raw/install-shopify-cli.sh)"

Install aliases

The script will detect if using bash or zsh and install accordingly

$SHELL -c "$(curl -fsSL https://gist.githubusercontent.com/njbmartin/af0445347a29ec00686713061d2d1138/raw/install-aliases.sh)"
#!/bin/sh
if [ -n "$ZSH_VERSION" ]; then
echo "# shopify aliases
alias sdev='shopify theme dev -s=\$(pwd | rev | cut -d \"(\" -f 1 | rev | cut -d \")\" -f 1).myshopify.com'
alias spull='shopify theme pull -s=\$(pwd | rev | cut -d \"(\" -f 1 | rev | cut -d \")\" -f 1).myshopify.com'
alias spush='shopify theme push -s=\$(pwd | rev | cut -d \"(\" -f 1 | rev | cut -d \")\" -f 1).myshopify.com'
alias senrich='curl -H \"Authorization: token \${GITHUB_PAT}\" -H \"Accept: application/vnd.github.v3.raw\" \
-o snippets/skio-plan-picker.liquid \"https://api.github.com/repos/skio-org/boilerplate-theme-code/contents/snippets/skio-plan-picker.liquid?ref=main\" \
-o snippets/skio-details.liquid \"https://api.github.com/repos/skio-org/boilerplate-theme-code/contents/snippets/skio-details.liquid?ref=main\" \
-o snippets/skio-cart-label.liquid \"https://api.github.com/repos/skio-org/boilerplate-theme-code/contents/snippets/skio-cart-label.liquid?ref=main\" \
-o snippets/skio-head.liquid \"https://api.github.com/repos/skio-org/boilerplate-theme-code/contents/snippets/skio-head.liquid?ref=main\" \
-o assets/skio-plan-picker.js \"https://api.github.com/repos/skio-org/boilerplate-theme-code/contents/assets/skio-plan-picker.js?ref=main\" \
-o assets/skio-plan-picker.css \"https://api.github.com/repos/skio-org/boilerplate-theme-code/contents/assets/skio-plan-picker.css?ref=main\"'" > ~/.oh-my-zsh/custom/shopify-aliases.zsh
echo "installed ~/.oh-my-zsh/custom/shopify-aliases.zsh"
elif [ -n "$BASH_VERSION" ]; then
# assume Bash
# create alias file
echo "# shopify aliases
alias sdev='shopify theme dev -s=\$(pwd | rev | cut -d \"(\" -f 1 | rev | cut -d \")\" -f 1).myshopify.com'
alias spull='shopify theme pull -s=\$(pwd | rev | cut -d \"(\" -f 1 | rev | cut -d \")\" -f 1).myshopify.com'
alias spush='shopify theme push -s=\$(pwd | rev | cut -d \"(\" -f 1 | rev | cut -d \")\" -f 1).myshopify.com'
alias senrich='curl -H \"Authorization: token \${GITHUB_PAT}\" -H \"Accept: application/vnd.github.v3.raw\" \
-o snippets/skio-plan-picker.liquid \"https://api.github.com/repos/skio-org/boilerplate-theme-code/contents/snippets/skio-plan-picker.liquid?ref=main\" \
-o snippets/skio-details.liquid \"https://api.github.com/repos/skio-org/boilerplate-theme-code/contents/snippets/skio-details.liquid?ref=main\" \
-o snippets/skio-cart-label.liquid \"https://api.github.com/repos/skio-org/boilerplate-theme-code/contents/snippets/skio-cart-label.liquid?ref=main\" \
-o snippets/skio-head.liquid \"https://api.github.com/repos/skio-org/boilerplate-theme-code/contents/snippets/skio-head.liquid?ref=main\" \
-o assets/skio-plan-picker.js \"https://api.github.com/repos/skio-org/boilerplate-theme-code/contents/assets/skio-plan-picker.js?ref=main\" \
-o assets/skio-plan-picker.css \"https://api.github.com/repos/skio-org/boilerplate-theme-code/contents/assets/skio-plan-picker.css?ref=main\"'" > ~/.shopify_aliases
echo "Created ~/.shopify_aliases"
if ! grep -q "# shopify aliases" ~/.bashrc; then
# add alias file to .bashrc
echo "
# shopify aliases
if [ -f ~/.shopify_aliases ]; then
. ~/.shopify_aliases
fi" >> ~/.bashrc
echo "Added ~/.shopify_aliases to ~/.bashrc"
else
echo "Alias file already installed"
fi
else
# assume something else
echo "not compatible"
fi
#!/bin/sh
if [ ! "$(type -t node)" ]; then
echo "Node must be installed first"
exit 1;
fi
if [ ! "$(type -t shopify)" ]; then
echo "Installing Shopify CLI..."
# install Shopify CLI + Themes (via node)
npm install -g @shopify/cli @shopify/theme
else
echo "Shopify CLI is already installed"
fi
alias sdev='shopify theme dev -s=$(pwd | rev | cut -d "(" -f 1 | rev | cut -d ")" -f 1).myshopify.com'
alias spull='shopify theme pull -s=$(pwd | rev | cut -d "(" -f 1 | rev | cut -d ")" -f 1).myshopify.com'
alias spush='shopify theme push -s=$(pwd | rev | cut -d "(" -f 1 | rev | cut -d ")" -f 1).myshopify.com'
alias senrich='curl -H "Authorization: token ${GITHUB_PAT}" -H "Accept: application/vnd.github.v3.raw" \
-o snippets/skio-plan-picker.liquid "https://api.github.com/repos/skio-org/boilerplate-theme-code/contents/snippets/skio-plan-picker.liquid?ref=main" \
-o snippets/skio-details.liquid "https://api.github.com/repos/skio-org/boilerplate-theme-code/contents/snippets/skio-details.liquid?ref=main" \
-o snippets/skio-cart-label.liquid "https://api.github.com/repos/skio-org/boilerplate-theme-code/contents/snippets/skio-cart-label.liquid?ref=main" \
-o snippets/skio-head.liquid "https://api.github.com/repos/skio-org/boilerplate-theme-code/contents/snippets/skio-head.liquid?ref=main" \
-o assets/skio-plan-picker.js "https://api.github.com/repos/skio-org/boilerplate-theme-code/contents/assets/skio-plan-picker.js?ref=main" \
-o assets/skio-plan-picker.css "https://api.github.com/repos/skio-org/boilerplate-theme-code/contents/assets/skio-plan-picker.css?ref=main"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment