Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat setup for alpine linux / zsh #1069

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 106 additions & 56 deletions .aliases
Original file line number Diff line number Diff line change
@@ -1,4 +1,61 @@
#!/usr/bin/env bash
### Aliases

alias listaliases="alias | sed 's/=.*//'"
alias listfunctions="declare -f | grep '^[a-z].* ()' | sed 's/{$//'" # show non _prefixed functions

# Dotfiles
alias dotfiles="atom ~/.dotfiles"
alias setup="cd ~/.dotfiles/setup"
alias init="setup; source init.sh"
alias bootstrap="set -- -f; source ~/.dotfiles/setup/bootstrap.sh"
alias macos="source ~/.dotfiles/setup/macos"

# CLI shortcuts
alias g="git"
alias y='yarn '

## Git
alias gc="git clone "
alias ungit="find . -name '.git' -exec rm -rf {} \;" # Remove git from a project

# Yarn
alias yi='yarn install '
alias ya='yarn add '
alias yp='yarn pods'
alias ys='yarn start'
alias yt='yarn test'
alias yr='y; yp; ys'
alias yrm='ycc; rm -rf node_modules; yi'
alias ycc='yarn cache clean'
alias yag='yarn global add'

alias ni='npm install'
alias nid='npm install --save-dev'
alias nig='npm install --global'
alias nt='npm test'
alias nit='npm install && npm test'
alias nr='npm run'
alias ns='npm start'
alias nrm='rm -rf node_modules && npm install'

alias p="pip"
alias pi="pip install "
alias pir="pip install -r requirements.txt"


## Networking
alias ip="curl icanhazip.com"
#alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias myip="curl http://ipecho.net/plain; echo"
alias locip="ipconfig getifaddr en0"
alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
alias cap="curl -s 'http://captive.apple.com'"

# HTTPie aliases
alias GET='http'
alias POST='http POST'
alias HEAD='http HEAD'

# Easier navigation: .., ..., ...., ....., ~ and -
alias ..="cd .."
Expand All @@ -8,12 +65,8 @@ alias .....="cd ../../../.."
alias ~="cd ~" # `cd` is probably faster to type though
alias -- -="cd -"

# Shortcuts
alias d="cd ~/Documents/Dropbox"
alias dl="cd ~/Downloads"
alias dt="cd ~/Desktop"
alias p="cd ~/projects"
alias g="git"
# copy the working directory path
alias cpwd='pwd|tr -d "\n"|pbcopy'

# Detect which `ls` flavor is in use
if ls --color > /dev/null 2>&1; then # GNU `ls`
Expand Down Expand Up @@ -42,26 +95,27 @@ alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'

# Enable aliases to be sudo’ed
alias sudo='sudo '

# Get week number
alias week='date +%V'

# Get macOS Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages
alias update='sudo softwareupdate -i -a; brew update; brew upgrade; brew cleanup; npm install npm -g; npm update -g; sudo gem update --system; sudo gem update; sudo gem cleanup'
## System commands

# Google Chrome
alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
alias canary='/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'
alias logoff="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
alias reboot='sudo shutdown -r now'
alias shutdown='sudo shutdown -h now'
alias dark='darkmode'
alias light='darkmode'

# IP addresses
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="ipconfig getifaddr en0"
alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
# info
alias displays="system_profiler SPDisplaysDataType"
alias cpuinfo="sysctl -n machdep.cpu.brand_string"
alias cpu='top -o cpu' # CPU
alias mem='top -o rsize' # Memory
# Disk
alias df='df -h'
alias du='du -h'
alias disk="df -Tha --total"

# Show active network interfaces
alias ifactive="ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'"
# Get week number
alias week='date +%V'
alias kw='week'

# Flush Directory Service cache
alias flush="dscacheutil -flushcache && killall -HUP mDNSResponder"
Expand All @@ -84,41 +138,14 @@ jscbin="/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources
unset jscbin;

# Trim new lines and copy to clipboard
alias c="tr -d '\n' | pbcopy"
#alias c="tr -d '\n' | pbcopy"

# Recursively delete `.DS_Store` files
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"

# Empty the Trash on all mounted volumes and the main HDD.
# Also, clear Apple’s System Logs to improve shell startup speed.
# Finally, clear download history from quarantine. https://mths.be/bum
alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl; sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'"

# Show/hide hidden files in Finder
alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"

# Hide/show all desktop icons (useful when presenting)
alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"

# URL-encode strings
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'

# Merge PDF files, preserving hyperlinks
# Usage: `mergepdf input{1,2,3}.pdf`
alias mergepdf='gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=_merged.pdf'

# Disable Spotlight
alias spotoff="sudo mdutil -a -i off"
# Enable Spotlight
alias spoton="sudo mdutil -a -i on"

# PlistBuddy alias, because sometimes `defaults` just doesn’t cut it
alias plistbuddy="/usr/libexec/PlistBuddy"

# Airport CLI alias
alias airport='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport'

# Intuitive map function
# For example, to list all directories that contain a certain file:
Expand All @@ -130,9 +157,8 @@ for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
alias "${method}"="lwp-request -m '${method}'"
done

# Stuff I never really use but cannot delete either because of http://xkcd.com/530/
alias stfu="osascript -e 'set volume output muted true'"
alias pumpitup="osascript -e 'set volume output volume 100'"
# Make Grunt print stack traces by default
command -v grunt > /dev/null && alias grunt="grunt --stack"

# Kill all the tabs in Chrome to free up memory
# [C] explained: http://www.commandlinefu.com/commands/view/402/exclude-grep-from-your-grepped-output-of-ps-alias-included-in-description
Expand All @@ -142,7 +168,31 @@ alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v exten
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"

# Reload the shell (i.e. invoke as a login shell)
alias reload="exec ${SHELL} -l"
alias reload='exec ${SHELL} -l'

# Print each PATH entry on a separate line
alias path='echo -e ${PATH//:/\\n}'
alias paths='echo -e ${PATH//:/\\n}'

# Convenience
alias please="sudo"
alias rl="reload"
alias ud="update"
alias sd="bootstrap"
alias f="finder"
alias c="clear"
alias x="exit"
alias e="x"
alias quit="exit"

## Typo
alias sl="ls"
alias bsh="bash"

## lol

alias shrug="printf '¯\_(ツ)_/¯' | pbcopy"
alias flipt="printf '(╯°□°)╯︵ ┻━┻' | pbcopy"
alias fight="printf '(ง'̀-'́)ง' | pbcopy"

# alias wtf='hint'
alias rtfm='man'
3 changes: 3 additions & 0 deletions .bash_profile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ shopt -s histappend;
# Autocorrect typos in path names when using `cd`
shopt -s cdspell;

# Enable storing directories in variables and cd'ing to them without '$' (check mark())
shopt -s cdable_vars

# Enable some Bash 4 features when possible:
# * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux`
# * Recursive globbing, e.g. `echo **/*.txt`
Expand Down
74 changes: 42 additions & 32 deletions .bash_prompt
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,55 @@ prompt_git() {
local branchName='';

# Check if the current directory is in a Git repository.
git rev-parse --is-inside-work-tree &>/dev/null || return;
if [ $(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}") == '0' ]; then


# check if the current directory is in .git before running git checks
if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == 'false' ]; then

# Ensure the index is up to date.
git update-index --really-refresh -q &>/dev/null;

# Check for what branch we’re on.
# Get the short symbolic ref. If HEAD isn’t a symbolic ref, get a
# tracking remote branch or tag. Otherwise, get the
# short SHA for the latest commit, or give up.
branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \
branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \
git describe --all --exact-match HEAD 2> /dev/null || \
git rev-parse --short HEAD 2> /dev/null || \
echo '(unknown)')";

# Early exit for Chromium & Blink repo, as the dirty check takes too long.
# Thanks, @paulirish!
# https://github.com/paulirish/dotfiles/blob/dd33151f/.bash_prompt#L110-L123
repoUrl="$(git config --get remote.origin.url)";
if grep -q 'chromium/src.git' <<< "${repoUrl}"; then
s+='*';
else
# Check for uncommitted changes in the index.
if ! $(git diff --quiet --ignore-submodules --cached); then
s+='+';
fi;
# Check for unstaged changes.
if ! $(git diff-files --quiet --ignore-submodules --); then
s+='!';
fi;
# Check for untracked files.
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
s+='?';
fi;
# Check for stashed files.
if $(git rev-parse --verify refs/stash &>/dev/null); then
s+='$';
fi;
fi;
git rev-parse --short HEAD 2> /dev/null || \
echo '(unknown)')";

# Early exit for Chromium & Blink repo, as the dirty check takes too long.
# Thanks, @paulirish!
# https://github.com/paulirish/dotfiles/blob/dd33151f/.bash_prompt#L110-L123
repoUrl="$(git config --get remote.origin.url)";
if grep -q 'chromium/src.git' <<< "${repoUrl}"; then
s+='*';
else
# Check for uncommitted changes in the index.
if ! $(git diff --quiet --ignore-submodules --cached); then
s+='+';
fi;
# Check for unstaged changes.
if ! $(git diff-files --quiet --ignore-submodules --); then
s+='!';
fi;
# Check for untracked files.
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
s+='?';
fi;
# Check for stashed files.
if $(git rev-parse --verify refs/stash &>/dev/null); then
s+='$';
fi;
fi;

[ -n "${s}" ] && s=" [${s}]";
[ -n "${s}" ] && s=" [${s}]";

echo -e "${1}${branchName}${2}${s}";
echo -e "${1}${branchName}${2}${s}";
fi;
else
return;
fi;
}

if tput setaf 1 &> /dev/null; then
Expand Down
18 changes: 16 additions & 2 deletions .gitconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
c = clone --recursive

# Commit all changes.
ca = !git add ':(exclude,attr:builtin_objectmode=160000)' && git commit -av
ca = !git add -Av && git commit -av

# Switch to a branch, creating it if necessary.
go = "!f() { git checkout -b \"$1\" 2> /dev/null || git checkout \"$1\"; }; f"
Expand Down Expand Up @@ -65,6 +65,17 @@

# Show the user email for the current repository.
whoami = config user.email
# Merge GitHub pull request on top of the current branch or,
# if a branch name is specified, on top of the specified branch
# rbmr = "!f() { \
# declare currentBranch=\"$(git symbolic-ref --short HEAD)\"; \
# declare branch=\"${2:-$currentBranch}\"; \
# if [ $(printf \"%s\" \"$1\" | grep '^[0-9]\\+$' > /dev/null; printf $?) -eq 0 ]; then \
# git fetch origin refs/pull/$1/head:pr/$1 && \
# git checkout -B $branch && \
# git rebase -i $branch pr/$1
# fi \
# }; f"

[apply]

Expand Down Expand Up @@ -156,6 +167,9 @@
# Make `git push` push relevant annotated tags when pushing branches out.
followTags = true

[github]
user = "ahemed-haneen"

# URL shorthands

[url "git@github.com:"]
Expand All @@ -180,4 +194,4 @@

[init]

defaultBranch = main
defaultBranch = main
4 changes: 4 additions & 0 deletions .zsh_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Add `~/bin` to the `$PATH`
export PATH="$HOME/bin:$PATH";

setopt cdablevars;
Loading