added better zshrc support to setup script
This commit is contained in:
parent
05f6707371
commit
2312859450
54
setup.sh
54
setup.sh
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e # exit on error
|
||||||
|
|
||||||
# This script sets up dotfiles and installs opencode:
|
# This script sets up dotfiles and installs opencode:
|
||||||
# - Backs up and symlinks .tmux.conf from dotfiles/ to ~/
|
# - Backs up and symlinks .tmux.conf from dotfiles/ to ~/
|
||||||
@ -6,20 +7,30 @@
|
|||||||
# - Installs opencode CLI if not already present
|
# - Installs opencode CLI if not already present
|
||||||
|
|
||||||
# Check and backup/symlink .tmux.conf
|
# Check and backup/symlink .tmux.conf
|
||||||
if [ -f ~/.tmux.conf ] || [ -L ~/.tmux.conf ]; then
|
TMUX_TARGET="$HOME/.config/nvim/dotfiles/.tmux.conf"
|
||||||
cp ~/.tmux.conf ~/.tmux.conf.backup
|
if [ -L ~/.tmux.conf ] && [ "$(readlink ~/.tmux.conf)" = "$TMUX_TARGET" ]; then
|
||||||
ln -sf ~/.config/nvim/dotfiles/.tmux.conf ~/.tmux.conf
|
echo ".tmux.conf already linked correctly"
|
||||||
elif [ -f ~/.config/nvim/.tmux.conf ]; then
|
elif [ -f ~/.tmux.conf ] || [ -L ~/.tmux.conf ]; then
|
||||||
cp ~/.config/nvim/dotfiles/.tmux.conf ~/.tmux.conf
|
cp ~/.tmux.conf ~/.tmux.conf.backup.$(date +%Y%m%d%H%M%S)
|
||||||
|
ln -sf "$TMUX_TARGET" ~/.tmux.conf
|
||||||
|
echo ".tmux.conf backed up and linked"
|
||||||
|
elif [ -f "$TMUX_TARGET" ]; then
|
||||||
|
ln -sf "$TMUX_TARGET" ~/.tmux.conf
|
||||||
|
echo ".tmux.conf linked"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check and backup/symlink starship.toml
|
# Check and backup/symlink starship.toml
|
||||||
if [ -f ~/.config/starship.toml ] || [ -L ~/.config/starship.toml ]; then
|
STARSHIP_TARGET="$HOME/.config/nvim/dotfiles/starship.toml"
|
||||||
cp ~/.config/starship.toml ~/.config/starship.toml.backup
|
if [ -L ~/.config/starship.toml ] && [ "$(readlink ~/.config/starship.toml)" = "$STARSHIP_TARGET" ]; then
|
||||||
ln -sf ~/.config/nvim/dotfiles/starship.toml ~/.config/starship.toml
|
echo "starship.toml already linked correctly"
|
||||||
elif [ -f ~/.config/nvim/starship.toml ]; then
|
elif [ -f ~/.config/starship.toml ] || [ -L ~/.config/starship.toml ]; then
|
||||||
|
cp ~/.config/starship.toml ~/.config/starship.toml.backup.$(date +%Y%m%d%H%M%S)
|
||||||
|
ln -sf "$STARSHIP_TARGET" ~/.config/starship.toml
|
||||||
|
echo "starship.toml backed up and linked"
|
||||||
|
elif [ -f "$STARSHIP_TARGET" ]; then
|
||||||
mkdir -p ~/.config
|
mkdir -p ~/.config
|
||||||
cp ~/.config/nvim/dotfiles/starship.toml ~/.config/starship.toml
|
ln -sf "$STARSHIP_TARGET" ~/.config/starship.toml
|
||||||
|
echo "starship.toml linked"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if opencode is installed, if not, install opencode
|
# Check if opencode is installed, if not, install opencode
|
||||||
@ -61,29 +72,34 @@ alias cldyo='claude --dangerously-skip-permissions --model opus'
|
|||||||
# IP address lookup
|
# IP address lookup
|
||||||
alias whatismyip="whatsmyip"
|
alias whatismyip="whatsmyip"
|
||||||
function whatsmyip () {
|
function whatsmyip () {
|
||||||
# Internal IP Lookup.
|
# Internal IP Lookup - auto-detect default interface
|
||||||
if command -v ip &> /dev/null; then
|
if command -v ip &> /dev/null; then
|
||||||
|
local iface=$(ip route | grep default | awk '{print $5}' | head -1)
|
||||||
echo -n "Internal IP: "
|
echo -n "Internal IP: "
|
||||||
ip addr show wlan0 | grep "inet " | awk '{print $2}' | cut -d/ -f1
|
ip addr show "$iface" | grep "inet " | awk '{print $2}' | cut -d/ -f1
|
||||||
else
|
else
|
||||||
echo -n "Internal IP: "
|
echo -n "Internal IP: "
|
||||||
ifconfig wlan0 | grep "inet " | awk '{print $2}'
|
ifconfig | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}' | head -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# External IP Lookup
|
# External IP Lookup
|
||||||
echo -n "External IP: "
|
echo -n "External IP: "
|
||||||
curl -4 ifconfig.me
|
curl -s -4 ifconfig.me
|
||||||
|
echo # newline after curl output
|
||||||
}
|
}
|
||||||
|
|
||||||
# Automatically do an ls after each cd
|
# Automatically do an ls after each cd
|
||||||
cd ()
|
if [[ -n "$ZSH_VERSION" ]]; then
|
||||||
{
|
chpwd() { ls }
|
||||||
|
else
|
||||||
|
cd() {
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
builtin cd "$@" && ls
|
builtin cd "$@" && ls
|
||||||
else
|
else
|
||||||
builtin cd ~ && ls
|
builtin cd ~ && ls
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
# Create and go to the directory
|
# Create and go to the directory
|
||||||
mkdirg() {
|
mkdirg() {
|
||||||
@ -128,8 +144,8 @@ alias ...='cd ../..'
|
|||||||
alias ....='cd ../../..'
|
alias ....='cd ../../..'
|
||||||
alias .....='cd ../../../..'
|
alias .....='cd ../../../..'
|
||||||
|
|
||||||
# Check the window size after each command
|
# Check the window size after each command (bash only)
|
||||||
shopt -s checkwinsize
|
[[ -n "$BASH_VERSION" ]] && shopt -s checkwinsize
|
||||||
|
|
||||||
# Set the default editor
|
# Set the default editor
|
||||||
export EDITOR=nvim
|
export EDITOR=nvim
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user