summaryrefslogtreecommitdiff
path: root/.zshrc
blob: 2173b194b8d7c92c2bcc716168f27c3d38c5aa8d (plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/bin/zsh

# Exports

export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"

export XDG_DOWNLOAD_DIR="${HOME}/downloads"
export XDG_CONFIG_HOME="${HOME}/.config"
export XDG_CACHE_HOME="${HOME}/.cache"
export XDG_DATA_HOME="${HOME}/.local/share"
export XDG_DESKTOP_DIR="${HOME}/desktop"
export XDG_TEMPLATES_DIR="${HOME}/temp"
export XDG_PUBLICSHARE_DIR="${HOME}/public"
export XDG_DOCUMENTS_DIR="${HOME}/documents"
export XDG_MUSIC_DIR="${HOME}/music"
export XDG_PICTURES_DIR="${HOME}/pictures"
export XDG_VIDEOS_DIR="${HOME}/videos"

export PATH="$PATH:$HOME/.cargo/bin"

export EDITOR="nvim"

export HISTFILE="${HOME}/.zsh_history"
export HISTCONTROL="ignoredups:ignorespace"
export HISTSIZE="100000"
export HISTFILESIZE="200000"
export SAVEHIST="${HISTSIZE}"

# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
# ┃ Functions                         		                  ┃
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

# === Media ===
function video-to-gif() {
  fps="$3"
  if [[ "$3" == "" ]];
  then 
    fps="10"
  fi

  ffmpeg \
    -i "$1" \
    -filter_complex \
    $(printf "%s%s%s%s" \
      "[0:v]setpts=0.5*PTS,fps=" \
      $fps \
      ",scale=800:-1:flags=lanczos,split[s0][s1];" \
      "[s0]palettegen[p];[s1][p]paletteuse") \
    -filter:a 'atempo=1,atempo=1' \
    -loop 0 \
    "$2"
}

function cut() {
	start_time="$1"
	end_time="$2"
	input_file="$3"

	if [[ "$end_time" == "" ]]; then
		ffmpeg -ss "$start_time" \
			-i "$input_file" \
			-c copy "$(date +"%Y%m%d_%H%M ")$input_file" \
			|| printf "Usage: %s <start> <end> <input file>\n" "$0"
	elif [[ "$end_time" != "" ]]; then
		ffmpeg -ss "$start_time" -to "$end_time" \
			-i "$input_file" \
			-c copy "$(date +"%Y%m%d_%H%M ")$input_file" \
			|| printf "Usage: %s <start> <end> <input file>\n" "$0"
	fi
}

# make an executable file w/ one line
function tx(){
	file="$1"
	[[ "$file" == "" ]] && echo -e "Usage: $0 <file name>\n"
	if [ -f "$file" ]; then
		echo "$file already exists. Making it executable."
		chmod +x "$file"
	else
		touch "$file" && chmod +x "$file"
	fi
}

# Waydroid
function droid(){
	case "$1" in
		stop)
			waydroid session stop
			;;
		restart)
			if [ pgrep -a waydroid != "" ]; then
				waydroid session stop
				setsid -f waydroid session start
			else
				setsid -f waydroid session start
			fi
			;;
		*)
			printf "Usage: %s {start|stop}\n" "$0"
			exit 1
	esac
}

# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
# ┃ ZSH Plugins                         		                ┃
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛


ZSH_CUSTOM="$HOME/.config/zsh/plugins"

plugins=(
  zsh-autosuggestions
  zsh-syntax-highlighting
)

for plugin in $plugins; do
  source "$ZSH_CUSTOM/$plugin/${plugin}.zsh"
done

ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#999999"

# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
# ┃ Completion system (modern menu)		                      ┃
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

autoload -Uz compinit && compinit
zstyle ':completion:*' menu select	# arrow-key menu
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'  # case insensitive
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" # colored completion
zstyle ':completion:*' rehash true                # auto-refresh completion if new programs installed

# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
# ┃ Keybinds		            			                          ┃
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

bindkey '^[[Z' autosuggest-accept   # Shift+Tab accepts suggestion
bindkey '^ ' autosuggest-accept     # Ctrl+Space also accepts
bindkey '^[[A' history-beginning-search-backward  # Up arrow: search history
bindkey '^[[B' history-beginning-search-forward   # Down arrow: search history

# Common bindings for Alt + Arrow (Meta + Arrow)
bindkey '^[[1;3C' forward-word      # Alt + Right
bindkey '^[[1;3D' backward-word     # Alt + Left

# cd into a directory with fzf
source <(fzf --zsh)

bindkey -s '^F' '~/.local/bin/tmux-sessionizer\n'

# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
# ┃ Alias		            	    		                          ┃
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

alias ls='ls --color=auto --group-directories-first'
alias ll='ls -lh --color=auto --group-directories-first'
alias la='ls -lah --color=auto --group-directories-first'
alias grep='grep --color=auto'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'

# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
# ┃ Prompt with git status		            	                ┃
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

# Load version control info
autoload -Uz vcs_info

# Load colors
autoload -Uz colors && colors

# Run vcs_info before each prompt
precmd_functions+=(vcs_info)

# Enable prompt substitution
setopt prompt_subst

# Configure the format for git
zstyle ':vcs_info:git:*' formats ' (%b)'
zstyle ':vcs_info:git:*' enable git

# Set the PROMPT variable to include the vcs_info_msg_0_ variable
PROMPT='%F{#bb9af7}%~%f%F{#7dcfff}${vcs_info_msg_0_}%f %# '