Instantly share code, notes, and snippets.
Last active
November 17, 2017 15:53
-
Star
(0)
0
You must be signed in to star a gist -
Fork
(0)
0
You must be signed in to fork a gist
-
Save AhiyaHiya/9166732e7f3087be1ef1f622fee199c1 to your computer and use it in GitHub Desktop.
My favorites aliases for both bash and zsh (oh my zsh)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# For both zsh and bash | |
# | |
##################### | |
# Cool terminal notification app but message only works with single quote | |
alias tnot="terminal-notifier -message " | |
##################### | |
# clang-format | |
alias cformat=~/Development/Tools/clang+llvm-4.0.0-x86_64-apple-darwin/bin/clang-format | |
##################### | |
# swift-format | |
alias sformat="swiftformat --indent 4 --allman true" | |
##################### | |
# copy path | |
alias pwdcp="pwd|pbcopy" | |
##################### | |
# From ubuntu | |
#alias ll='ls -alF' | |
alias ll='ls -FGlAhp' | |
alias la='ls -A' | |
alias l='ls -CF' | |
alias ls='ls -1' | |
alias lss='ls -GFh' | |
##################### | |
# From https://natelandau.com/my-mac-osx-bash_profile/ | |
alias mkdir='mkdir -pv' | |
mcd () { mkdir -p "$1" && cd "$1"; } | |
cd() { builtin cd "$@"; ll; } | |
alias path='echo -e ${PATH//:/\\n}' | |
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'' | less' | |
cdf () { | |
currFolderPath=$( /usr/bin/osascript <<EOT | |
tell application "Finder" | |
try | |
set currFolder to (folder of the front window as alias) | |
on error | |
set currFolder to (path to desktop folder as alias) | |
end try | |
POSIX path of currFolder | |
end tell | |
EOT | |
) | |
echo "cd to \"$currFolderPath\"" | |
cd "$currFolderPath" | |
} | |
extract () { | |
if [ -f $1 ] ; then | |
case $1 in | |
*.tar.bz2) tar xjf $1 ;; | |
*.tar.gz) tar xzf $1 ;; | |
*.bz2) bunzip2 $1 ;; | |
*.rar) unrar e $1 ;; | |
*.gz) gunzip $1 ;; | |
*.tar) tar xf $1 ;; | |
*.tbz2) tar xjf $1 ;; | |
*.tgz) tar xzf $1 ;; | |
*.zip) unzip $1 ;; | |
*.Z) uncompress $1 ;; | |
*.7z) 7z x $1 ;; | |
*) echo "'$1' cannot be extracted via extract()" ;; | |
esac | |
else | |
echo "'$1' is not a valid file" | |
fi | |
} | |
alias qfind="find . -name " # qfind: Quickly search for file | |
ff () { /usr/bin/find . -name "$@" ; } # ff: Find file under the current directory | |
ffs () { /usr/bin/find . -name "$@"'*' ; } # ffs: Find file whose name starts with a given string | |
ffe () { /usr/bin/find . -name '*'"$@" ; } # ffe: Find file whose name ends with a given string | |
##################### | |
# | |
alias myip='curl ip.appspot.com' | |
ii() { | |
echo -e "\nYou are logged on ${RED}$HOST" | |
echo -e "\nAdditionnal information:$NC " ; uname -a | |
echo -e "\n${RED}Users logged on:$NC " ; w -h | |
echo -e "\n${RED}Current date :$NC " ; date | |
echo -e "\n${RED}Machine stats :$NC " ; uptime | |
echo -e "\n${RED}Current network location :$NC " ; scselect | |
echo -e "\n${RED}Public facing IP Address :$NC " ;myip | |
#echo -e "\n${RED}DNS Configuration:$NC " ; scutil --dns | |
echo | |
} | |
##################### | |
# Git | |
alias gta="git add" | |
alias gtc="git commit -m" | |
alias gtf="git fetch" | |
alias gtpl="git pull" | |
alias gtps="git push" | |
alias gts="git status" | |
alias gtebd="git branch --edit-description" | |
# git branch list | |
# nice function thanks to https://github.com/bahmutov/git-branches#adding-to-bash_profile | |
function gtlb() { | |
branch="" | |
branches=`git branch --list` | |
while read -r branch; do | |
clean_branch_name=${branch//\*\ /} | |
description=`git config branch.$clean_branch_name.description` | |
printf "%-15s %s\n" "$branch" "$description" | |
done <<< "$branches" | |
} | |
# Nice functions from https://gist.github.com/dciccale/5560837 | |
function parse_git_dirty() { | |
git diff --quiet --ignore-submodules HEAD 2>/dev/null; [ $? -eq 1 ] && echo "*" | |
} | |
# git current branch | |
# lists the current git branch | |
function gtcb() { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" | |
} | |
# git branch description print | |
function gtpbd(){ | |
readonly local GIT_BRANCH=$(gtcb) | |
git config branch.${GIT_BRANCH}.description | |
} | |
##################### | |
# Perforce | |
# standard p4 init command with options | |
alias p4in="p4 init -C0 -n" | |
# other p4 commands | |
alias p4e="p4 edit" | |
alias p4sb="p4 submit -d" | |
alias p4f="p4 fetch" | |
alias p4ps="p4 push" | |
alias p4s="p4 status" | |
alias p4r="p4 rec" | |
alias p4rm="p4 -u jaime clone -p perforceserver:1666 -r " | |
alias p4lg="p4 -u jaime -p perforceserver:1666 login" | |
# fix p4v issue with local server not loading in app | |
alias p4vfix="echo Removing p4v app preferences;rm -Rv ~/Library/Preferences/com.perforce.p4v/" | |
##################### | |
# Xcode | |
alias xcddd="sudo rm -fR ~/Library/Developer/Xcode/DerivedData/*" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment