Add Zed config and clean up aliases
This commit is contained in:
58
.bashrc
58
.bashrc
@@ -12,7 +12,7 @@ fi
|
|||||||
if [ -f /etc/os-release ]; then
|
if [ -f /etc/os-release ]; then
|
||||||
distro=$(awk -F= '/^NAME/{print $ssss2}' /etc/os-release | tr -d '"')
|
distro=$(awk -F= '/^NAME/{print $ssss2}' /etc/os-release | tr -d '"')
|
||||||
if [[ "$distro" == *"Pop!_OS"* ]]; then
|
if [[ "$distro" == *"Pop!_OS"* ]]; then
|
||||||
export CGO_CFLAGS="-I/usr/include"
|
export CGO_CFLAGS="-I/usr/include"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -63,9 +63,7 @@ alias gcb='git checkout -b'
|
|||||||
|
|
||||||
# Kubernetes aliases (Minikube)
|
# Kubernetes aliases (Minikube)
|
||||||
alias kubectl="minikube kubectl --"
|
alias kubectl="minikube kubectl --"
|
||||||
|
alias zed=zeditor
|
||||||
# netstat port in use check
|
|
||||||
alias port='netstat -atupn | grep LISTEN'
|
|
||||||
|
|
||||||
# Check if a specific port is in use with detailed process information
|
# Check if a specific port is in use with detailed process information
|
||||||
inuse() {
|
inuse() {
|
||||||
@@ -77,7 +75,7 @@ inuse() {
|
|||||||
local CYAN='\033[0;36m'
|
local CYAN='\033[0;36m'
|
||||||
local BOLD='\033[1m'
|
local BOLD='\033[1m'
|
||||||
local NC='\033[0m' # No Color
|
local NC='\033[0m' # No Color
|
||||||
|
|
||||||
# Input validation
|
# Input validation
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
echo -e "${RED}Usage:${NC} inuse <port_number>"
|
echo -e "${RED}Usage:${NC} inuse <port_number>"
|
||||||
@@ -87,7 +85,7 @@ inuse() {
|
|||||||
echo -e "${YELLOW} inuse --list${NC}"
|
echo -e "${YELLOW} inuse --list${NC}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Handle --help option
|
# Handle --help option
|
||||||
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
|
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
|
||||||
echo -e "${CYAN}${BOLD}inuse - Check if a port is in use${NC}"
|
echo -e "${CYAN}${BOLD}inuse - Check if a port is in use${NC}"
|
||||||
@@ -114,24 +112,24 @@ inuse() {
|
|||||||
echo
|
echo
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Handle --list option
|
# Handle --list option
|
||||||
if [ "$1" = "--list" ] || [ "$1" = "-l" ]; then
|
if [ "$1" = "--list" ] || [ "$1" = "-l" ]; then
|
||||||
if ! command -v docker >/dev/null 2>&1; then
|
if ! command -v docker >/dev/null 2>&1; then
|
||||||
echo -e "${RED}Error:${NC} Docker is not available"
|
echo -e "${RED}Error:${NC} Docker is not available"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "${CYAN}${BOLD}Docker Services with Listening Ports:${NC}"
|
echo -e "${CYAN}${BOLD}Docker Services with Listening Ports:${NC}"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# Get all running containers
|
# Get all running containers
|
||||||
local containers=$(docker ps --format "{{.Names}}" 2>/dev/null)
|
local containers=$(docker ps --format "{{.Names}}" 2>/dev/null)
|
||||||
if [ -z "$containers" ]; then
|
if [ -z "$containers" ]; then
|
||||||
echo -e "${YELLOW}No running Docker containers found${NC}"
|
echo -e "${YELLOW}No running Docker containers found${NC}"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local found_services=false
|
local found_services=false
|
||||||
while IFS= read -r container; do
|
while IFS= read -r container; do
|
||||||
# Get port mappings for this container
|
# Get port mappings for this container
|
||||||
@@ -140,9 +138,9 @@ inuse() {
|
|||||||
# Get container image name (clean it up)
|
# Get container image name (clean it up)
|
||||||
local image=$(docker inspect "$container" 2>/dev/null | grep -o '"Image": *"[^"]*"' | cut -d'"' -f4 | head -1)
|
local image=$(docker inspect "$container" 2>/dev/null | grep -o '"Image": *"[^"]*"' | cut -d'"' -f4 | head -1)
|
||||||
local clean_image=$(echo "$image" | sed 's/sha256:[a-f0-9]*/[image-hash]/' | sed 's/^.*\///')
|
local clean_image=$(echo "$image" | sed 's/sha256:[a-f0-9]*/[image-hash]/' | sed 's/^.*\///')
|
||||||
|
|
||||||
echo -e "${GREEN}📦 ${BOLD}$container${NC} ${CYAN}($clean_image)${NC}"
|
echo -e "${GREEN}📦 ${BOLD}$container${NC} ${CYAN}($clean_image)${NC}"
|
||||||
|
|
||||||
# Parse and display ports nicely
|
# Parse and display ports nicely
|
||||||
echo "$ports" | while IFS= read -r port_line; do
|
echo "$ports" | while IFS= read -r port_line; do
|
||||||
if [[ "$port_line" =~ ([0-9]+)/(tcp|udp).*0\.0\.0\.0:([0-9]+) ]]; then
|
if [[ "$port_line" =~ ([0-9]+)/(tcp|udp).*0\.0\.0\.0:([0-9]+) ]]; then
|
||||||
@@ -161,7 +159,7 @@ inuse() {
|
|||||||
found_services=true
|
found_services=true
|
||||||
fi
|
fi
|
||||||
done <<< "$containers"
|
done <<< "$containers"
|
||||||
|
|
||||||
# Also check for host networking containers
|
# Also check for host networking containers
|
||||||
local host_containers=$(docker ps --format "{{.Names}}" --filter "network=host" 2>/dev/null)
|
local host_containers=$(docker ps --format "{{.Names}}" --filter "network=host" 2>/dev/null)
|
||||||
if [ -n "$host_containers" ]; then
|
if [ -n "$host_containers" ]; then
|
||||||
@@ -174,22 +172,22 @@ inuse() {
|
|||||||
echo
|
echo
|
||||||
found_services=true
|
found_services=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$found_services" = false ]; then
|
if [ "$found_services" = false ]; then
|
||||||
echo -e "${YELLOW}No Docker services with exposed ports found${NC}"
|
echo -e "${YELLOW}No Docker services with exposed ports found${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local port="$1"
|
local port="$1"
|
||||||
|
|
||||||
# Validate port number
|
# Validate port number
|
||||||
if ! [[ "$port" =~ ^[0-9]+$ ]] || [ "$port" -lt 1 ] || [ "$port" -gt 65535 ]; then
|
if ! [[ "$port" =~ ^[0-9]+$ ]] || [ "$port" -lt 1 ] || [ "$port" -gt 65535 ]; then
|
||||||
echo -e "${RED}Error:${NC} Invalid port number. Must be between 1 and 65535."
|
echo -e "${RED}Error:${NC} Invalid port number. Must be between 1 and 65535."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if port is in use first
|
# Check if port is in use first
|
||||||
local port_in_use=false
|
local port_in_use=false
|
||||||
if command -v ss >/dev/null 2>&1; then
|
if command -v ss >/dev/null 2>&1; then
|
||||||
@@ -201,15 +199,15 @@ inuse() {
|
|||||||
port_in_use=true
|
port_in_use=true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$port_in_use" = false ]; then
|
if [ "$port_in_use" = false ]; then
|
||||||
echo -e "${RED}✗ Port $port is FREE${NC}"
|
echo -e "${RED}✗ Port $port is FREE${NC}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Port is in use, now find what's using it
|
# Port is in use, now find what's using it
|
||||||
local found_process=false
|
local found_process=false
|
||||||
|
|
||||||
# Method 1: Try netstat first (most reliable for PID info)
|
# Method 1: Try netstat first (most reliable for PID info)
|
||||||
if command -v netstat >/dev/null 2>&1; then
|
if command -v netstat >/dev/null 2>&1; then
|
||||||
local netstat_result=$(netstat -tulpn 2>/dev/null | grep ":$port ")
|
local netstat_result=$(netstat -tulpn 2>/dev/null | grep ":$port ")
|
||||||
@@ -218,7 +216,7 @@ inuse() {
|
|||||||
local pid=$(echo "$line" | awk '{print $7}' | cut -d'/' -f1)
|
local pid=$(echo "$line" | awk '{print $7}' | cut -d'/' -f1)
|
||||||
local process_name=$(echo "$line" | awk '{print $7}' | cut -d'/' -f2)
|
local process_name=$(echo "$line" | awk '{print $7}' | cut -d'/' -f2)
|
||||||
local protocol=$(echo "$line" | awk '{print $1}')
|
local protocol=$(echo "$line" | awk '{print $1}')
|
||||||
|
|
||||||
if [[ "$pid" =~ ^[0-9]+$ ]] && [ -n "$process_name" ]; then
|
if [[ "$pid" =~ ^[0-9]+$ ]] && [ -n "$process_name" ]; then
|
||||||
# Check if it's a Docker container
|
# Check if it's a Docker container
|
||||||
local docker_info=""
|
local docker_info=""
|
||||||
@@ -246,14 +244,14 @@ inuse() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "${GREEN}✓ Port $port ($protocol) in use by ${BOLD}$process_name${NC} ${GREEN}as PID ${BOLD}$pid${NC}$docker_info"
|
echo -e "${GREEN}✓ Port $port ($protocol) in use by ${BOLD}$process_name${NC} ${GREEN}as PID ${BOLD}$pid${NC}$docker_info"
|
||||||
found_process=true
|
found_process=true
|
||||||
fi
|
fi
|
||||||
done <<< "$netstat_result"
|
done <<< "$netstat_result"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Method 2: Try ss if netstat didn't work
|
# Method 2: Try ss if netstat didn't work
|
||||||
if [ "$found_process" = false ] && command -v ss >/dev/null 2>&1; then
|
if [ "$found_process" = false ] && command -v ss >/dev/null 2>&1; then
|
||||||
local ss_result=$(ss -tulpn 2>/dev/null | grep ":$port ")
|
local ss_result=$(ss -tulpn 2>/dev/null | grep ":$port ")
|
||||||
@@ -261,7 +259,7 @@ inuse() {
|
|||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
local pid=$(echo "$line" | grep -o 'pid=[0-9]*' | cut -d'=' -f2)
|
local pid=$(echo "$line" | grep -o 'pid=[0-9]*' | cut -d'=' -f2)
|
||||||
local protocol=$(echo "$line" | awk '{print $1}')
|
local protocol=$(echo "$line" | awk '{print $1}')
|
||||||
|
|
||||||
if [[ "$pid" =~ ^[0-9]+$ ]]; then
|
if [[ "$pid" =~ ^[0-9]+$ ]]; then
|
||||||
local process_name=$(ps -p "$pid" -o comm= 2>/dev/null)
|
local process_name=$(ps -p "$pid" -o comm= 2>/dev/null)
|
||||||
if [ -n "$process_name" ]; then
|
if [ -n "$process_name" ]; then
|
||||||
@@ -287,7 +285,7 @@ inuse() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "${GREEN}✓ Port $port ($protocol) in use by ${BOLD}$process_name${NC} ${GREEN}as PID ${BOLD}$pid${NC}$docker_info"
|
echo -e "${GREEN}✓ Port $port ($protocol) in use by ${BOLD}$process_name${NC} ${GREEN}as PID ${BOLD}$pid${NC}$docker_info"
|
||||||
found_process=true
|
found_process=true
|
||||||
fi
|
fi
|
||||||
@@ -295,7 +293,7 @@ inuse() {
|
|||||||
done <<< "$ss_result"
|
done <<< "$ss_result"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Method 3: Try fuser as last resort
|
# Method 3: Try fuser as last resort
|
||||||
if [ "$found_process" = false ] && command -v fuser >/dev/null 2>&1; then
|
if [ "$found_process" = false ] && command -v fuser >/dev/null 2>&1; then
|
||||||
local fuser_pids=$(fuser "$port/tcp" 2>/dev/null)
|
local fuser_pids=$(fuser "$port/tcp" 2>/dev/null)
|
||||||
@@ -312,7 +310,7 @@ inuse() {
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Method 4: Check for Docker containers more accurately
|
# Method 4: Check for Docker containers more accurately
|
||||||
if [ "$found_process" = false ] && command -v docker >/dev/null 2>&1; then
|
if [ "$found_process" = false ] && command -v docker >/dev/null 2>&1; then
|
||||||
# First, try to find containers with published ports matching our port
|
# First, try to find containers with published ports matching our port
|
||||||
@@ -343,13 +341,13 @@ inuse() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If we still haven't found the process, show a generic message
|
# If we still haven't found the process, show a generic message
|
||||||
if [ "$found_process" = false ]; then
|
if [ "$found_process" = false ]; then
|
||||||
echo -e "${YELLOW}⚠ Port $port is in use but unable to identify the process${NC}"
|
echo -e "${YELLOW}⚠ Port $port is in use but unable to identify the process${NC}"
|
||||||
echo -e "${CYAN} This might be due to insufficient permissions or the process being in a different namespace${NC}"
|
echo -e "${CYAN} This might be due to insufficient permissions or the process being in a different namespace${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,6 +10,18 @@
|
|||||||
// #############################################
|
// #############################################
|
||||||
// ## Theming ##
|
// ## Theming ##
|
||||||
// #############################################
|
// #############################################
|
||||||
|
"ssh_connections": [
|
||||||
|
{
|
||||||
|
"host": "desktop",
|
||||||
|
"projects": [
|
||||||
|
{
|
||||||
|
"paths": [
|
||||||
|
"/home/menno/.dotfiles"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"icon_theme": "VSCode Icons (Dark)",
|
"icon_theme": "VSCode Icons (Dark)",
|
||||||
"ui_font_size": 16,
|
"ui_font_size": 16,
|
||||||
"buffer_font_size": 16,
|
"buffer_font_size": 16,
|
||||||
@@ -22,7 +34,7 @@
|
|||||||
"theme": {
|
"theme": {
|
||||||
"mode": "system",
|
"mode": "system",
|
||||||
"light": "Catppuccin Latte",
|
"light": "Catppuccin Latte",
|
||||||
"dark": "Catppuccin Frappé"
|
"dark": "Catppuccin Macchiato"
|
||||||
},
|
},
|
||||||
"tabs": {
|
"tabs": {
|
||||||
"close_position": "right",
|
"close_position": "right",
|
||||||
@@ -58,8 +70,7 @@
|
|||||||
"default_model": {
|
"default_model": {
|
||||||
"provider": "zed.dev",
|
"provider": "zed.dev",
|
||||||
"model": "claude-sonnet-4"
|
"model": "claude-sonnet-4"
|
||||||
},
|
}
|
||||||
"version": "2"
|
|
||||||
},
|
},
|
||||||
"edit_predictions": {
|
"edit_predictions": {
|
||||||
"mode": "subtle",
|
"mode": "subtle",
|
||||||
|
Reference in New Issue
Block a user