move from fish to zsh in mac.

Ditching fish because its a PAIN IN THE ASS TO WORK WITH
This commit is contained in:
juancwu 2023-10-01 14:41:17 -04:00
commit a974024add
No known key found for this signature in database
6 changed files with 125 additions and 22 deletions

View file

@ -1,3 +1,7 @@
# Config file for macOS
eval "$(/opt/homebrew/bin/brew shellenv)"
#
# set -x NVM_DIR "$HOME/.nvm"
#
# nvm use >/dev/null

View file

@ -49,21 +49,6 @@ if type -q tmux
alias tmks "tmux kill-session"
end
if type -q nvm
nvm use >/dev/null
end
if type -q lazygit
alias lg "lazygit"
end
function fish_greeting
echo "Welcome Back Juan!"
if type -q nvm
echo "Current Node:$(nvm current)"
end
end
# allow local config overwrite
set LOCAL_CONFIG (dirname (status --current-file))/config-local.fish
if test -f $LOCAL_CONFIG
@ -71,10 +56,8 @@ if test -f $LOCAL_CONFIG
end
# pnpm
set -gx PNPM_HOME "/home/jc/.local/share/pnpm"
set -gx PNPM_HOME "/Users/jc/Library/pnpm"
if not string match -q -- $PNPM_HOME $PATH
set -gx PATH "$PNPM_HOME" $PATH
end
# pnpm end
# bun
set --export BUN_INSTALL "$HOME/.bun"
set --export PATH $BUN_INSTALL/bin $PATH

View file

@ -4,7 +4,8 @@ return {
dependencies = {
-- LSP Support
{ 'neovim/nvim-lspconfig' }, -- Required
{ -- Optional
{
-- Optional
'williamboman/mason.nvim',
build = function()
pcall(vim.cmd, 'MasonUpdate')
@ -81,6 +82,7 @@ return {
if status then
lspconfig.tsserver.setup({})
lspconfig.tailwindcss.setup({})
lspconfig.zls.setup({})
end
lspzero.setup()

2
.config/zsh/aliases.zsh Normal file
View file

@ -0,0 +1,2 @@
alias ll='ls -l'
alias lla='ls -la'

87
.config/zsh/functions.zsh Normal file
View file

@ -0,0 +1,87 @@
# list directory and cd into it
sd() {
local path=${1:-.}
local result=$(ls -d ${path}/*/ 2> /dev/null | fzf)
if [[ -n "${result}" ]]; then
cd "${result}"
else
echo "No directories found or no selection made."
fi
}
# list files and opens it in neovim
sf() {
local path=${2:-.}
if [[ $1 == "-h" ]]; then
local result=$(find ${path} -type f -name '.*' 2> /dev/null | fzf)
else
local result=$(find ${path} -type f 2> /dev/null | fzf)
fi
if [[ -n "${result}" ]]; then
nvim "${result}"
else
echo "No files found or no selecteion made."
fi
}
# fuzzy cd into specific folders
fcd() {
local selected_dir=$({
echo "$HOME/.config"
find "$HOME/ghq" -mindepth 2 -maxdepth 2 -type d
ls -d -1 "$HOME/"/*/ | grep -v \.git
ls -d -1 */ | perl -pe "s#^#$PWD/#" | grep -v \.git
} | fzf)
if [ -n "$selected_dir" ]; then
cd "$selected_dir"
if [[ -f .nvmrc ]]; then
NVMRC_VERSION=$(cat .nvmrc)
CURRENT_VERSION=$(nvm current)
if [ "$NVMRC_VERSIOn" != "$CURRENT_VERSION" ]; then
nvm use
fi
fi
else
echo "No selection made."
fi
}
# clone repository
# setopt EXTENDED_GLOB
gc() {
local url=$1
local ghq_dir="$HOME/ghq"
# extract project name
if [[ $url =~ git@github\.com:([^/]+)/([^/]+)\.git ]]; then
local project_name="${match[1]}"
local repository_name="${match[2]}"
elif [[ $url =~ https://github\.com/([^/]+)/([^/]+)\.git ]]; then
local project_name="${match[1]}"
local repository_name="${match[2]}"
else
echo "Invalid URL format"
return 1
fi
# check if directory for project exists or not
local project_dir="${ghq_dir}/${project_name}/${repository_name}"
echo $project_dir
if [[ ! -d $project_dir ]]; then
mkdir -p $project_dir
fi
git clone $url $project_dir
}
# get branch if available
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# delete local branches that don't exists in remote repository
git-prune() {
git fetch --prune
git branch -vv | grep '\[origin/.*: gone\]' | awk '{print $1}' | xargs git branch -d
}

25
.config/zsh/zshrc.zsh Normal file
View file

@ -0,0 +1,25 @@
ZSH_CONFIG="$(dirname ${(%):-%x})"
# Functions!
source "$ZSH_CONFIG/dotfiles/.config/zsh/functions.zsh"
# Aliases
source "$ZSH_CONFIG/dotfiles/.config/zsh/aliases.zsh"
export PATH=/Users/jc/Library/Python/3.8/bin:$PATH
export BREW_PYTHON=/opt/homebrew/bin/python3
# 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
# bun completions
[ -s "/Users/jc/.bun/_bun" ] && source "/Users/jc/.bun/_bun"
# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
# PRETTIERD
export PRETTIERD_DEFAULT_CONFIG="$HOME/.prettierrc.json"