Skip to content

Instantly share code, notes, and snippets.

@rolroralra
Last active November 10, 2022 02:20
Show Gist options
  • Save rolroralra/f045493dbe9d15e8d9af606dad1251de to your computer and use it in GitHub Desktop.
Save rolroralra/f045493dbe9d15e8d9af606dad1251de to your computer and use it in GitHub Desktop.
Mac OS

pbcopy, pbpaste

https://jojoldu.tistory.com/466


jenv

https://inma.tistory.com/157


netstat -nltp

lsof -i -P | grep LISTEN
netstat -nat | grep LISTEN

oh-my-zsh Install

Details

# https://github.com/ohmyzsh/ohmyzsh
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

$ sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"


Bash-Completion

Details

$ brew install bash-completion

Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
act                   clair                 flank                 jinx                  mandown               po4a                  sonic
amp                   cloudformation-cli    folderify             jobber                marked                promtail              standardese
apidoc                coconut               functionalplus        jsonnet-bundler       naabu                 pwncat                subfinder
arb                   colfer                gateway-go            k9s                   nanorc                [email protected]            termcolor
argo                  copilot               gcc@9                 kde-kdoctools         nest                  reg                   terraform-ls
argocd                cortex                git-hooks-go          kona                  networkit             rgf                   thanos
arrayfire             cpio                  gofish                ksync                 never                 rqlite                uptoc
awsweeper             cpm                   golangci-lint         kubie                 ngs                   s2n                   vapor
bond                  croaring              gradle-profiler       latexindent           notmuch-mutt          saltwater             vgrep
buildozer             cubejs-cli            grpcui                ldpl                  oci-cli               scw@1                 vsearch
cadence               dnsprobe              gulp-cli              litecli               omake                 sdns                  wgcf
carton                doctest               hasura-cli            logcli                oq                    simdjson              wren
chalk-cli             dosbox-staging        heksa                 loki                  ory-hydra             skylighting           wren-cli
chart-testing         duckscript            hy                    lunchy                osi                   smlpkg                yj
choose-rust           eksctl                jerryscript           lunchy-go             pandoc-include-code   so                    z.lua
chrony                fennel                jimtcl                macos-trash           pipgrip               solidity              zoxide
==> Updated Formulae
Updated 4099 formulae.
==> Renamed Formulae
[email protected] -> elasticsearch@6                 [email protected] -> kibana@6                               mkl-dnn -> onednn
==> Deleted Formulae
cargo-completion      [email protected]     highlighting-kate     [email protected]            marathon-swift        sflowtool             unravel
cryptopp              [email protected]     i386-elf-grub         lumo                  python                tomee-jax-rs

==> Downloading https://homebrew.bintray.com/bottles/bash-completion-1.3_3.catalina.bottle.tar.gz
######################################################################## 100.0%
==> Pouring bash-completion-1.3_3.catalina.bottle.tar.gz
==> Caveats
Add the following line to your ~/.bash_profile:
  [[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
🍺  /usr/local/Cellar/bash-completion/1.3_3: 189 files, 607.9KB
==> `brew cleanup` has not been run in 30 days, running now...
Removing: /Users/shinyoungkim/Library/Logs/Homebrew/ncurses... (64B)
Removing: /Users/shinyoungkim/Library/Logs/Homebrew/pcre... (64B)
Removing: /Users/shinyoungkim/Library/Logs/Homebrew/zsh... (64B)


How to install nodejs, npm (Just install nvm, and then install node, npm)

Details

$ brew install nvm

$ nvm install 12.8.3

$ node -v
$ npm -v
$ nvm -v
$ nvm list


How to find command path in zsh

$ type -a node

.zshrc

Details

alias ll="ls -alt"

# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/shinyoungkim/Downloads/google-cloud-sdk/path.zsh.inc' ]; then . '/Users/shinyoungkim/Downloads/google-cloud-sdk/path.zsh.inc'; fi

# The next line enables shell command completion for gcloud.
if [ -f '/Users/shinyoungkim/Downloads/google-cloud-sdk/completion.zsh.inc' ]; then . '/Users/shinyoungkim/Downloads/google-cloud-sdk/completion.zsh.inc'; fi

# Kubectl Auto Complete for zsh
[[ $commands[kubectl] ]] && source <(kubectl completion zsh)

# GCloud Auto Completion for zsh
#fpath=(/Users/shinyoungkim/Workspace/gcloud/gcloud-zsh-completion/src $fpath)
source "/Users/shinyoungkim/Downloads/google-cloud-sdk/path.zsh.inc"
source "/Users/shinyoungkim/Downloads/google-cloud-sdk/completion.zsh.inc"

# nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
source <(npm completion)

# pip
alias pip=pip3
alias python=python3
source <(python -m pip completion --zsh)

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/shinyoungkim/opt/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/shinyoungkim/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/shinyoungkim/opt/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/Users/shinyoungkim/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<


# >>> Setting /etc/hosts config >>>
CURRENT_MY_IP=$(curl ifconfig.me 2>/dev/null)
export ROLRORLARA_EXT_IP="112.155.121.85"
export ROLRORLARA_INN_IP="192.168.219.196"
if [ ${CURRENT_MY_IP} != ${ROLRORALRA_EX_IP} ]
then
  sed -i "s/^#${ROLRORLARA_INN_IP}/${ROLRORLARA_INN_IP}/g" /etc/hosts
else
  sed -i "s/^${ROLRORLARA_INN_IP}/#${ROLRORLARA_INN_IP}/g" /etc/hosts
fi
# <<< Setting /etc/hosts config <<<

# zsh auto completion setting (/wrt line number 75)
autoload -U	compinit && compinit


Mount SFTP Network Drive

Details

#!/bin/bash

# >>> Setting /etc/hosts config >>>
CURRENT_MY_IP=$(curl ifconfig.me 2>/dev/null)
ROLRORLARA_EXT_IP=${ROLROALRA_EXT_IP:-"112.155.121.85"}
ROLRORLARA_INN_IP=${ROLROALRA_INN_IP:-"192.168.219.196"}
if [ ${CURRENT_MY_IP} != ${ROLRORALRA_EX_IP} ]
then
  sed -i "s/^#${ROLRORLARA_INN_IP}/${ROLRORLARA_INN_IP}/g" /etc/hosts
  remote_ssh_port=${DEFAULT_REMOTE_EXT_SSH_PORT:-22}
else
  sed -i "s/^${ROLRORLARA_INN_IP}/#${ROLRORLARA_INN_IP}/g" /etc/hosts
  remote_ssh_port=${DEFAULT_REMOTE_INN_SSH_PORT:-22}
fi
# <<< Setting /etc/hosts config <<<

# set values
remote_user="rolroralra"
remote_host="rolroralra.com"
remote_ssh_port=${remote_ssh_port:-22}
remote_home="/home/torrent"
local_user="shinyoungkim"
local_home="/Users/${local_user}/mount"
remote_volume_name="rolroralra-remote"

# exec command
OUTPUT=`sshfs ${remote_user}@${remote_host}:${remote_home} ${local_home} -p ${remote_ssh_port} -ovolname=${remote_volume_name}`
echo $OUTPUT


Why can't I quit Finder with the shortcut (cmd+q)

https://apple.stackexchange.com/questions/304717/why-cant-i-quit-finder-with-the-shortcut-cmdq


Install JDK 8

Details

$ brew install openjdk@8
...

For the system Java wrappers to find this JDK, symlink it with
  sudo ln -sfn /usr/local/opt/openjdk@8/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-8.jdk

openjdk@8 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have openjdk@8 first in your PATH run:
  echo 'export PATH="/usr/local/opt/openjdk@8/bin:$PATH"' >> ~/.zshrc

For compilers to find openjdk@8 you may need to set:
  export CPPFLAGS="-I/usr/local/opt/openjdk@8/include"

How to manage multiple java version in mac os (jenv)

  • /usr/libexec/java_home

https://advenoh.tistory.com/20

  • jenv

https://jogeum.net/15

$ brew install jenv
...

Error: Your CLT does not support macOS 11.
It is either outdated or was modified.
Please update your CLT or delete it if no updates are available.
Update them from Software Update in System Preferences or run:
  softwareupdate --all --install --force

If that doesn't show you an update run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/more/.

Error: An exception occurred within a child process:
  SystemExit: exit
  
$ brew install jenv
...

To activate jenv, add the following to your ~/.zshrc:

  export PATH="$HOME/.jenv/bin:$PATH"
  eval "$(jenv init -)"


/etc/hosts ISSUE

InetAddress.getLocalHost().getHostName() took 5007 milliseconds to respond. Please verify your network configuration (macOS machines may need to add entries to /etc/hosts)

Solution
https://dzone.com/articles/macos-sierra-problems-with-javanetinetaddress-getl

$ sudo vi /etc/hosts
127.0.0.1	localhost MacBook-Pro.local
255.255.255.255	broadcasthost
::1             localhost

Install Apache Tomcat 9

Details

$ brew search tomcat 
==> Formulae
tomcat              tomcat-native       tomcat@7            tomcat@8

$ brew install tomcat
...
For the system Java wrappers to find this JDK, symlink it with
  sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

openjdk is keg-only, which means it was not symlinked into /usr/local,
because it shadows the macOS `java` wrapper.

If you need to have openjdk first in your PATH, run:
  echo 'export PATH="/usr/local/opt/openjdk/bin:$PATH"' >> ~/.zshrc

For compilers to find openjdk you may need to set:
  export CPPFLAGS="-I/usr/local/opt/openjdk/include"

==> tomcat
To have launchd start tomcat now and restart at login:
  brew services start tomcat
Or, if you don't want/need a background service you can just run:
  catalina run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment