---
title: Terminate a program by port on Mac
layout: post
---

Sometimes I need to kill a process. I always have to Google how to do that again. Not anymore. Put this function in `~/.bash_profile`.

{% highlight bash %}
# terminate function
terminate () {
  lsof -i "tcp:$1" | tail -1 | awk '{print $2}' | xargs kill -9&& echo "Killed proces on port $1" || echo "Failed to kill proces on port $1"
}
{% endhighlight %}

So now you can type `terminate 3000` to kill the process on port `3000`
---
title: Terminate a program by port on Mac
layout: post
---

Sometimes I need to kill a process. I always have to Google how to do that again. Not anymore. Put this function in `~/.bash_profile`.

```bash
# terminate function
terminate () {
  lsof -i "tcp:$1" | tail -1 | awk '{print $2}' | xargs kill -9&& echo "Killed proces on port $1" || echo "Failed to kill proces on port $1"
}
```

So now you can type `terminate 3000` to kill the process on port `3000`

Use default highlighter Rouge for Jekyll 3.0
Use default highlighter Rouge for Jekyll 3.0

https://github.com/blog/2100-github-pages-now-faster-and-simpler-with-jekyll-3-0