Skip to content

Instantly share code, notes, and snippets.

@jemshit
Last active May 6, 2020 08:33
Show Gist options
  • Save jemshit/68923787a3f8ba856fab9d43e4258483 to your computer and use it in GitHub Desktop.
Save jemshit/68923787a3f8ba856fab9d43e4258483 to your computer and use it in GitHub Desktop.
Custom .bash_profile for MacOs
#### cd to the path of the front Finder window
cdf() {
target=`osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)'`
if [ "$target" != "" ]; then
cd "$target"; pwd
else
echo 'No Finder window found' >&2
fi
}
#### Show Hidden Files
shf(){
/usr/bin/defaults write com.apple.finder AppleShowAllFiles YES
killall Finder /System/Library/CoreServices/Finder.app
}
#### Hide Hidden Files
hhf(){
/usr/bin/defaults write com.apple.finder AppleShowAllFiles NO
killall Finder /System/Library/CoreServices/Finder.app
}
### Info CPU
infoCpu(){
/usr/sbin/sysctl -n machdep.cpu.brand_string
}
#### Disable Lock Screen WiFi turn off feature
lockWifiOff(){
cd /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources
sudo ./airport en1 prefs DisconnectOnLogout=NO
}
### Disable System Assestment Security Policy
disableSPCTL(){
sudo spctl --master-disable
}
### Restart Audio
resA(){
sudo killall coreaudiod
}
### Screenshot location
changeScreenshotLocation(){
defaults write com.apple.screencapture location ~/Pictures/screenshots/
killall SystemUIServer
}
### clear terminal and history
cls() {
clear && printf '\e[3J'
}
### For colored terminal, also activate "Display ANSI colors" from Preferences
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
### change PATH
export PATH="/Users/codex/sdk/platform-tools":$PATH
export PATH="/Users/codex/sdk/tools":$PATH
export PATH="/Users/codex/sdk/build-tools/25.0.1":$PATH
# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
# When changing directory small typos can be ignored by bash
# for example, cd /vr/lgo/apaache would find /var/log/apache
shopt -s cdspell
# Display matches for ambiguous patterns at first tab press
bind "set show-all-if-ambiguous on"
# Grep aliases
alias grep='grep --color' # show differences in colour
alias egrep='egrep --color=auto' # show differences in colour
alias fgrep='fgrep --color=auto' # show differences in colour
###
export JAVA_HOME=$(/usr/libexec/java_home)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment