Add Zed config and clean up aliases

This commit is contained in:
2025-07-23 14:43:56 +02:00
parent b11c9a32a8
commit 37743d3512
2 changed files with 42 additions and 33 deletions

58
.bashrc
View File

@@ -12,7 +12,7 @@ fi
if [ -f /etc/os-release ]; then
distro=$(awk -F= '/^NAME/{print $ssss2}' /etc/os-release | tr -d '"')
if [[ "$distro" == *"Pop!_OS"* ]]; then
export CGO_CFLAGS="-I/usr/include"
export CGO_CFLAGS="-I/usr/include"
fi
fi
@@ -63,9 +63,7 @@ alias gcb='git checkout -b'
# Kubernetes aliases (Minikube)
alias kubectl="minikube kubectl --"
# netstat port in use check
alias port='netstat -atupn | grep LISTEN'
alias zed=zeditor
# Check if a specific port is in use with detailed process information
inuse() {
@@ -77,7 +75,7 @@ inuse() {
local CYAN='\033[0;36m'
local BOLD='\033[1m'
local NC='\033[0m' # No Color
# Input validation
if [ $# -eq 0 ]; then
echo -e "${RED}Usage:${NC} inuse <port_number>"
@@ -87,7 +85,7 @@ inuse() {
echo -e "${YELLOW} inuse --list${NC}"
return 1
fi
# Handle --help option
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
echo -e "${CYAN}${BOLD}inuse - Check if a port is in use${NC}"
@@ -114,24 +112,24 @@ inuse() {
echo
return 0
fi
# Handle --list option
if [ "$1" = "--list" ] || [ "$1" = "-l" ]; then
if ! command -v docker >/dev/null 2>&1; then
echo -e "${RED}Error:${NC} Docker is not available"
return 1
fi
echo -e "${CYAN}${BOLD}Docker Services with Listening Ports:${NC}"
echo
# Get all running containers
local containers=$(docker ps --format "{{.Names}}" 2>/dev/null)
if [ -z "$containers" ]; then
echo -e "${YELLOW}No running Docker containers found${NC}"
return 0
fi
local found_services=false
while IFS= read -r container; do
# Get port mappings for this container
@@ -140,9 +138,9 @@ inuse() {
# Get container image name (clean it up)
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/^.*\///')
echo -e "${GREEN}📦 ${BOLD}$container${NC} ${CYAN}($clean_image)${NC}"
# Parse and display ports nicely
echo "$ports" | while IFS= read -r port_line; do
if [[ "$port_line" =~ ([0-9]+)/(tcp|udp).*0\.0\.0\.0:([0-9]+) ]]; then
@@ -161,7 +159,7 @@ inuse() {
found_services=true
fi
done <<< "$containers"
# Also check for host networking containers
local host_containers=$(docker ps --format "{{.Names}}" --filter "network=host" 2>/dev/null)
if [ -n "$host_containers" ]; then
@@ -174,22 +172,22 @@ inuse() {
echo
found_services=true
fi
if [ "$found_services" = false ]; then
echo -e "${YELLOW}No Docker services with exposed ports found${NC}"
fi
return 0
fi
local port="$1"
# Validate port number
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."
return 1
fi
# Check if port is in use first
local port_in_use=false
if command -v ss >/dev/null 2>&1; then
@@ -201,15 +199,15 @@ inuse() {
port_in_use=true
fi
fi
if [ "$port_in_use" = false ]; then
echo -e "${RED}✗ Port $port is FREE${NC}"
return 1
fi
# Port is in use, now find what's using it
local found_process=false
# Method 1: Try netstat first (most reliable for PID info)
if command -v netstat >/dev/null 2>&1; then
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 process_name=$(echo "$line" | awk '{print $7}' | cut -d'/' -f2)
local protocol=$(echo "$line" | awk '{print $1}')
if [[ "$pid" =~ ^[0-9]+$ ]] && [ -n "$process_name" ]; then
# Check if it's a Docker container
local docker_info=""
@@ -246,14 +244,14 @@ inuse() {
fi
fi
fi
echo -e "${GREEN}✓ Port $port ($protocol) in use by ${BOLD}$process_name${NC} ${GREEN}as PID ${BOLD}$pid${NC}$docker_info"
found_process=true
fi
done <<< "$netstat_result"
fi
fi
# Method 2: Try ss if netstat didn't work
if [ "$found_process" = false ] && command -v ss >/dev/null 2>&1; then
local ss_result=$(ss -tulpn 2>/dev/null | grep ":$port ")
@@ -261,7 +259,7 @@ inuse() {
while IFS= read -r line; do
local pid=$(echo "$line" | grep -o 'pid=[0-9]*' | cut -d'=' -f2)
local protocol=$(echo "$line" | awk '{print $1}')
if [[ "$pid" =~ ^[0-9]+$ ]]; then
local process_name=$(ps -p "$pid" -o comm= 2>/dev/null)
if [ -n "$process_name" ]; then
@@ -287,7 +285,7 @@ inuse() {
fi
fi
fi
echo -e "${GREEN}✓ Port $port ($protocol) in use by ${BOLD}$process_name${NC} ${GREEN}as PID ${BOLD}$pid${NC}$docker_info"
found_process=true
fi
@@ -295,7 +293,7 @@ inuse() {
done <<< "$ss_result"
fi
fi
# Method 3: Try fuser as last resort
if [ "$found_process" = false ] && command -v fuser >/dev/null 2>&1; then
local fuser_pids=$(fuser "$port/tcp" 2>/dev/null)
@@ -312,7 +310,7 @@ inuse() {
done
fi
fi
# Method 4: Check for Docker containers more accurately
if [ "$found_process" = false ] && command -v docker >/dev/null 2>&1; then
# First, try to find containers with published ports matching our port
@@ -343,13 +341,13 @@ inuse() {
fi
fi
fi
# If we still haven't found the process, show a generic message
if [ "$found_process" = false ]; then
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}"
fi
return 0
}

View File

@@ -10,6 +10,18 @@
// #############################################
// ## Theming ##
// #############################################
"ssh_connections": [
{
"host": "desktop",
"projects": [
{
"paths": [
"/home/menno/.dotfiles"
]
}
]
}
],
"icon_theme": "VSCode Icons (Dark)",
"ui_font_size": 16,
"buffer_font_size": 16,
@@ -22,7 +34,7 @@
"theme": {
"mode": "system",
"light": "Catppuccin Latte",
"dark": "Catppuccin Frappé"
"dark": "Catppuccin Macchiato"
},
"tabs": {
"close_position": "right",
@@ -58,8 +70,7 @@
"default_model": {
"provider": "zed.dev",
"model": "claude-sonnet-4"
},
"version": "2"
}
},
"edit_predictions": {
"mode": "subtle",