-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc_personal
72 lines (61 loc) · 2.02 KB
/
.zshrc_personal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Return if not interactive
[[ $- != *i* ]] && return
# Shell Functions
debugpg() {
local usageMessage="
$0 SOURCE_FILE[S...]
A basic shell function that automates the
debugging task with gcc/g++ and gdb according
to appropritate file extensions
"
# perform input validation
# Select compiler from extension of first arg
local compiler
local stem=${1%%.*}
stem=${stem##*/}
local extension=${1##*.}
case "$extension" in
'cpp') compiler=g++ ;;
'c' ) compiler=gcc ;;
* ) echo -e 'Invalid Usage\n' "$usageMessage" >&2
return 1 ;;
esac
# make sure required programs are installed
# else return with appropriate error message
which $compiler >/dev/null || {echo "$compiler not installed" >&2; return 1}
which gdb >/dev/null || {echo "gdb debugger is not installed" >&2; return 1}
# Compile given program by supplying all the args
# to compiler with the -g flag
local dirname=/tmp/${0}
local binaryname=${dirname}/${stem}_debug.out
mkdir -p "$dirname" || {echo "Unable to create "$dirname" directory" >&2; return 1}
echo -e "Compiling... Saving build file as '$binaryname'"
$compiler -g -o "$binaryname" "$@" || return 1
# startup gdb with the executable
gdb --silent "$binaryname"
}
# Function to open nvim with selected config
function nvims() {
items=("default" "kickstart.nvim" "lazyvim" "nvchad" "astronvim")
config=$(printf "%s\n" "${items[@]}" | fzf --prompt=" Neovim Config >> " --height=~50% --layout=reverse --border --exit-0)
if [[ -z $config ]]; then
echo "Nothing selected"
return 0
elif [[ $config == "default" ]]; then
config=""
fi
NVIM_APPNAME=$config nvim $@
}
# Source aliases for zshrc
[[ -f ~/.aliases ]] && source ~/.aliases
# Source envvars for zshrc
[[ -f ~/.envvars ]] && source ~/.envvars
# Make zsh like vi
set -o vi
# Load startup configuration of zoxide
eval "$(zoxide init zsh)"
# Attach to a tmux session or create new if not already in a tmux
# session
if [ -z "$TMUX" ]; then
tmux attach 2>/dev/null || tmux new-session 2>/dev/null
fi