Compare commits

...

29 Commits
Hooks ... main

Author SHA1 Message Date
16201be750
chore(ZshPlug): Pull latest ZshPlug
Update submodule to the latest commit of ZshPlug
2024-02-19 18:02:05 +00:00
1f4cc35078
docs(Readme): update Readme
Add sentence about shelly
2024-02-19 17:27:47 +00:00
9392c2eb19
feat(gchup): Add support for loading gchup environment. 2024-02-19 15:17:27 +00:00
169cf0c209
feat(greet): Add TODO.md
Automatically display `~/TODO.md` if glow is installed
2024-02-19 15:16:14 +00:00
0100d1c64f
feat(theme): Add theme support
Add support for both pywal and theme.sh terminal themes
2024-02-19 15:14:55 +00:00
654a2ad327 fix(prompt)!: New NerdFont glyphs
Use the new NerdFont glyphs so that the git branch portion of the prompt
displays correctly.
BREAKING CHANGE: Any install using old NerdFonts will display incorrect
glyphs, This should be resolved by updating your NerdFont.
2024-02-19 15:13:34 +00:00
2ad568db03
feat(keyboard): Use paste and quote magic
Use both bracketed-paste-magic and url-quote-magic to make pasting urls
into the terminal a little nicer.
NOTE: In rare cases this can break things, and will slow down pasting.
2024-02-19 15:12:31 +00:00
cd0ec0c563
fix(hooks): Fix glow hook overriding glow command
Fix the issue where as the glow hook was called glow it would be called
instead of the command glow.
2024-02-19 14:57:25 +00:00
6a7f432e33
refactor(dir_aliases): Change Projects
Change projects hash alias to try `$Z_PROJECT_DIR` first before using
`$HOME/Projects`
2024-02-19 14:54:53 +00:00
1a18c13306
feat(aliases): add gp (goProject) alias
Add a simple alias that finds all projects in `$Z_PROJECT_DIR` if set
otherwise searches `$HOME/Projects`
2024-02-19 14:52:56 +00:00
08539a0de6
feat(aliases): Add support for eza
Use eza first, then exa to replace ls and tree
2024-02-19 14:51:24 +00:00
9da7b6babf
refactor: Change the way that all hooks work
Move hooks to a dedicated module.
This allows for greater flexibility and easier editing.

TODO: Make hook handling neater (possibly through parsing the hook
	script to read an "hook-to" marker that allows for automated
	loading of properly formatted hook functions)
2023-04-11 22:45:38 +01:00
43e3ce2765
refactor(prompt): Add hook in the conventional way
Change how I add the `vcs_info` function call to the `precmd` hook.
Using add-zsh-hook allows me to have multiple hook functions on `precmd`
and makes it clear what is done for each hook when listing them
2023-04-11 22:42:43 +01:00
c2f60ba7fd
feat(zshrc): Enable more options and Document
- Extended Globbing
- Chase Dots
- Mark Dirs
- rm Star Wait
- Interactive comments

These options have been enabled as I belive that I will find them
useful. For more information on functionality please see appropriate
documentation.
2023-04-11 00:00:02 +01:00
ef86f64945
fix(zshrc): Allow loading local site-functions
Some programs install completion to `~/.local/zsh/site-functions`
adding this path to `fpath` allows them to be loaded by `compinit`
2023-04-01 22:03:34 +01:00
7ad661267e
fix(zshrc): check for homebrew first
make zsh check if the homebrew directory is present before attempting to
load it.
2023-04-01 21:57:33 +01:00
a79e9e988f
fix(history): Change set to setopt
Kinda borked the history settings by using set instead of setopt
mia culpa
Fixed now
2023-04-01 21:54:05 +01:00
Robert Morrison
d99aa241fe
docs(Readme): Update Readme
Complete rewrite of Readme for hopefully better clarity.
Now covering all major features and differences
2022-12-06 23:31:00 +00:00
Robert Morrison
c46372add1
chore(completion): remove echoing of $fpath
Removed debugging echo statement from completion settings
2022-12-06 17:49:51 +00:00
Robert Morrison
a91c9a530e
chore: Remove executable bit from files
none of these files need to be marked as executable...
2022-12-06 17:47:59 +00:00
Robert Morrison
91252d1b54
refactor(prompt): Move set term title to precmd
Moved the setTermTitle function call out of the prompt line and into the
precmd hook.
This shortens the non-visible length of the prompt line and also makes
the functionality clearer
2022-12-06 16:24:32 +00:00
Robert Morrison
ab222a30c7
fix(chpwd): fix chpwd
Dumb syntax error fix
2022-12-05 21:39:02 +00:00
Robert Morrison
5d1484881e
fix: add some compatibility options
this commit introduces the `has` function.
Now I can ensure that any command I want to alias or call is available
first.

This should allow the config to automatically slot in even where systems
aren't configured in the way I would expect
2022-12-05 21:29:10 +00:00
Robert Morrison
a029d2f348
Mega Commit
This commit is a sin.
But necessary
2022-12-05 21:03:45 +00:00
Robert Morrison
9ff7659ada
Remove zkbd files.
No need to sync these over git as they are terminal and system specific
2022-02-20 01:42:49 +00:00
Robert Morrison
4970349c55
bugfix - load functions
Load functions by manipulating fpath
2022-02-20 01:40:09 +00:00
Robert Morrison
70822b11da
Update zshPlug to working version 2022-02-20 01:27:08 +00:00
Robert Morrison
acea2aed2c
Pull fixed zshPlug 2022-02-20 00:58:01 +00:00
Robert Morrison
bbf21d3b21
Functionify my tempPersist script 2022-02-20 00:11:49 +00:00
23 changed files with 527 additions and 108 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.zkbd/
.zcompdump
.zcalc_history

View File

@ -1,26 +0,0 @@
typeset -g -A key
key[F1]='^[OP'
key[F2]='^[OQ'
key[F3]='^[OR'
key[F4]='^[OS'
key[F5]='^[[15~'
key[F6]='^[[17~'
key[F7]='^[[18~'
key[F8]='^[[19~'
key[F9]='^[[20~'
key[F10]='^[[21~'
key[F11]='^[[23~'
key[F12]='^[[24~'
key[Backspace]='^?'
key[Insert]='^[[4h'
key[Home]='^[[H'
key[PageUp]='^[[5~'
key[Delete]='^[[P'
key[End]='^[[4~'
key[PageDown]='^[[6~'
key[Up]='^[[A'
key[Left]='^[[D'
key[Down]='^[[B'
key[Right]='^[[C'
key[Menu]=''''

204
Readme.md
View File

@ -1,34 +1,202 @@
# My ZSH config.
# My ZSH configuration
This is my personal ZSH config that I run on my laptop.
It works for what I want from a configured shell.
This repository has a fully loaded configuration for ZSH.
The configuration make opinionated choices based on my own desires for what
a shell should be like.
I would recommend you actually create your own config before just using
mine since you will gain a proper understanding of how ZSH works and just
what it can do.
It's strongly advised that you write your own configuration instead of
just using this one. That way you can understand what you are doing and
maybe gain a better appreciation for the shell and its features.
I have attempted to organise my config into a series of files that each
perform a specific task, that way it is easier for me to change small
sections as the need arises.
The configuration is broken down into modules where possible, this
makes it easier to hack on.
## How to use
## Usage
If you really really want to just blindly copy me then you will need to
clone this repository to `~/.config/zsh`
Clone this repository to `~/.config/zsh`
Inside of the cloned repository run:
Inside of that directory run:
```sh
git submodule init
git submodule update
```
This will pull in the latest version of my plugin manager.
This will pull my plug-in manager `ZshPlug`.
And then add the following into your `~/.profile`:
And then add the following into `~/.zshenv`:
```sh
export ZDOTDIR="${XDG_CONFIG_HOME:-$HOME/.config}/zsh"
```
This tells ZSH where the ZSH dotfiles are.
You may find that using my other dotfile package `shelly` makes life even
easier for you.
After your next reboot you _should_ be using my config.
If anything goes wrong feel free to open an issue. But this is entirely a
personal project for my own use, so don't expect anything.
### Important note
It is possible that your system might not be happy with this.
I have yet to fully work out the little issues that I have with making a
consistent environment across *all* of my user session.
This might result in a need to create a system of linked environment files
to ensure that everything can access the environment variables that are
meant to be set.
## Issues
This is a personal project and is unlikely to be maintained in a
professional manner.
If you do find any technical issues during your usage of this config then
feel free to open a GitHub issue.
Please remember that GitHub issues are not a forum nor a place for you to
ask questions not related to *technical issues*, and it is completely up to
my own discretion what issues I handle and which ones I close.
## General overview
The main goals for this configuration are look good, work good, and be
quick.
The less things getting in my way the better.
This is why I have made opinionated decisions about what options to enable
and how it works.
### Notable features
- Edit the command line in $EDITOR by pressing `C-x C-e`
- Fully configured completion
- Automatic typo repair
- vi mode enabled
- Automatic use of the directory stack `popd` to go back whence you came
- Smart history
- Plug-ins chosen for greatness
- Extended Globbing enabled.
- 10 second thinking time enforced for big deletes
- Expanded directories automatically have `/` appended
- Allow comments in interactive mode (this may be useful to mark history
items)
- Neaten paths like `../foo/..` to `..` (ChaseDots)
## Breakdown
The following sections break down what is in the repository and what
function it does.
### Modules
#### `./aliases`
This module features aliases that I find useful or ones that improve
existing tools.
Any alias that uses external tools uses the `has` function to disable it
when the tool isn't installed.
##### Current aliases:
- `ls` => `exa --icons --group-directories-first` (see: [Exa Website](https://the.exa.website/) )
- `xopen` => `xdg-open`
- `cls` => `clear; ls`
- `se` => `scriptedit` (wrapper script for fzf and nvim)
- `yt` => `youtube-dl`
- `yta` => `youtube-dl --ignore-config --add-metadata --ignore-errors --extract-audio --format "bestaudio/best"`
- `cp` => `cp --interactive --verbose`
- `mv` => `mv --interactive --verbose`
- `rm` => `rm --interactive=once --verbose`
- `mkd` => `mkdir --parents --verbose`
- `diff` => `diff --color=auto`
- `grep` => `grep --color=auto`
- `ip` => `ip --colour=auto`
- `vw` => `nvim -c VimwikiIndex`
- `ws` => `wineselect` (script to choose and set wine-prefix)
- `zero` => `dirs -c && clear`
##### File associations
This module is also responsible for in terminal file associations. Given a
file with a particular extension ZSH can open it with the appropriate
program.
`tex`, `html`, and `md` files are mapped to either `nvim`, `vim`, or `vi`
in that order of preference.
`pdf` files are mapped to `zathura` when it's installed.
#### `./completion`
This file configures the powerful completion engine of
ZSH.
Documenting this here would be a waste since the file has decent comments.
For more information on ZSH completion see `man zshcompsys`
#### `./dir_aliases`
This file uses `hash` to add entries into the named directory hash table.
(See: `man zshbuiltins`)
This gives the effect of these "aliases" that represent directories.
- `~dx` => `$HOME/Documents`
- `~dl` => `$HOME/Downloads`
- `~cn` => `${XDG_CONFIG_HOME:-$HOME/.config}`
- `~px` => `$HOME/Pictures`
- `~pr` => `$HOME/Projects`
#### `./greet`
This file gets executed at the end of `zshrc` to provide a little message
on startup.
#### `./history`
This file configures the ZSH history system.
This makes a few changes:
- Moves history to `${XDG_STATE_HOME/zsh/history}`
- Ignores duplicate entries
- Ignore entries starting with a space
- Compacts whitespace
- Never saves duplicates
- Ignores duplicates when searching history
- Requires you press enter after expanding `!!`
#### './hooks'
This file loads hook functions found in './hooks.d'
and makes it easier to assign hooks where necessary.
#### `./keyboard`
This file uses `zkbd`(see `man zshcontrib`) to get information about your
keyboard and how your terminal handles it. This can fix issues with keys
not being recognised in programs.
#### `./prompt`
This file configures the prompts, and yes there's two.
ZSH has both a left and right prompt and I use both of them.
##### Left prompt
The left prompt shows user, hostname, current directory, and the status of
the last command.
##### Right prompt
The right prompt shows the status of git repository information while
you're in one.
##### `precmd`
This file also sets the `precmd` hook to set the terminal title (for
terminals which support the escape codes that do this.)
#### `zshrc`
This is the true `zshrc` file with `.zshrc` a symbolic link to this
file.
This makes it a little easier to edit the file since you can actually see
it in `ls` and in editors.
This file draws together the modules and actually makes
settings apply.
### Functions
This configuration defines and loads some functions,
some of which are helper functions used in the configuration.
#### `CleanTmp`
Function called during exit to clean a local tmp directory (`~/tmp`).
#### `has`
Just a wrapper for calling `command -v $COMMAND`.
This function gets used to check for external tools.
#### `setTermTitle`
This function gets used in the prompt to set the terminal title.
It makes use of escape sequences to control the terminal and might have
issues on rare or unusual terminals.
#### `tempPersist`
This function controls if the local tmp directory (`~/tmp`) will persist across sessions or
not.
#### `_dotnet`
This completion function that tells the completion engine how to
complete `dotnet` commands.

@ -1 +1 @@
Subproject commit 3ddf1405d81861f1af4455e3716abd230b531a3f
Subproject commit 592295a85a89a27abe7c8424304c676630e80e58

46
aliases Executable file → Normal file
View File

@ -34,21 +34,26 @@
## Use Exa instead of ls
## REQUIRES NERD FONT
alias ls='exa --icons --group-directories-first'
has eza && EXA=eza || EXA=exa
has "$EXA" && alias ls="$EXA --icons --group-directories-first"
has "$EXA" && alias tree="$EXA --icons --group-directories-first --tree"
unset EXA
## Shorten xdg-open
alias xopen='xdg-open'
has xdg-open && alias xopen='xdg-open'
## cls Clear Screen run ls
alias cls='clear; ls'
## Shorten scriptedit
## REQUIRES scriptedit (Script)
alias se='scriptedit'
has scriptedit && alias se='scriptedit'
## YouTube downloader
alias yt='youtube-dl'
alias yta='youtube-dl --ignore-config --add-metadata --ignore-errors --extract-audio --format "bestaudio/best"'
if has youtube-dl ; then
alias yt='youtube-dl'
alias yta='youtube-dl --ignore-config --add-metadata --ignore-errors --extract-audio --format "bestaudio/best"'
fi
##
alias cp='cp --interactive --verbose'
@ -62,17 +67,38 @@ alias grep='grep --color=auto'
alias ip='ip --color=auto'
## Open Vimwiki
alias vw='nvim -c VimwikiIndex'
has nvim && alias vw='nvim -c VimwikiIndex'
## Change Wineprefix quick and EZ
has wineselect && alias ws='source wineselect'
## zero a terminal session
alias zero='dirs -c && clear'
has fzf && alias gp='cd `find ${Z_PROJECT_DIR:-$HOME/Projects} -type d -name .git | sed "s/.git//" | fzf --preview="cd {} && git log"`'
#########################
# FileType Associations #
# extension=program #
#########################
if has nvim; then
VIM=nvim
elif has vim; then
VIM=vim
elif has vi; then
VIM=vi
else
VIM=''
fi
alias -s tex=nvim
alias -s html=nvim
alias -s pdf=zathura
alias -s md=nvim
if [[ -n $VIM ]]; then
alias -s tex=$VIM
alias -s html=$VIM
alias -s md=$VIM
fi
unset $VIM
has zathura && alias -s pdf=zathura
# vim: set ft=zsh ts=2 sw=2 tw=0 noet :

65
completion Normal file
View File

@ -0,0 +1,65 @@
############
# Completion Config
############
## Disable beeping on completions.
setopt NO_BEEP
## Automatically list ambiguous completions.
setopt AUTO_LIST
## Automatically use menu completion after the second request for completion.
setopt AUTO_MENU
## Always fully insert completions.
setopt MENU_COMPLETE
## Automatically put subscripts directly after parameter expressions.
setopt AUTO_PARAM_KEYS
## Allow completion within words (i.e. always complete at the cursor position).
setopt COMPLETE_IN_WORD
## Always move the cursor to the end of a completion after inserting it.
setopt ALWAYS_TO_END
## Automatically list compleptions when given an unambigous prefix.
setopt LIST_AMBIGUOUS
## Display markers to indicate what type of file a completion item is.
setopt LIST_TYPES
## Print an error when provided patterns that are badly formed.
setopt BAD_PATTERN
zstyle ':completion:*' verbose yes
zstyle ':completion:*' group-name '' ## Simply makes the group-name appear with the group
zstyle ':completion:*' menu select ## use menu to select where possible
zstyle ':completion:*' completer _complete _match _approximate ## fuzzy match
zstyle ':completion:*' squeeze-slashes true ## remove trailing slashes
zstyle ':completion:*:descriptions' format '%B%F{green}┨%d┣%f%b' ## better descriptions format
zstyle ':completion:*:warnings' format '%BSorry, no matches for: %F{yellow}%d%b%f' ## show when no matches
zstyle ':completion:*:corrections' format '%B%F{yellow}┨%d┤├ errors %e┣%f%b'
zstyle ':completion:*:match:*' original only
zstyle -e ':completion:*:approximate:*' \
max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)' ## more errors in longer lines
zstyle ':completion:*:functions' ignored-patterns '_*' ## ignore completions for commands I dont have
zstyle ':completion:*:cd:*' ignore-parents parent pwd ## don't complete parent dir
autoload -Uz +X compinit
zmodload zsh/complist
compinit
# vim: ft=zsh

3
dir_aliases Executable file → Normal file
View File

@ -6,4 +6,5 @@ hash -d dx="$HOME/Documents"
hash -d dl="$HOME/Downloads"
hash -d cn="${XDG_CONFIG_HOME:-$HOME/.config}"
hash -d px="$HOME/Pictures"
hash -d pr="$HOME/Projects"
hash -d pr="${Z_PROJECT_DIR:-$HOME/Projects}"
# vim: ft=zsh

View File

@ -22,3 +22,4 @@ status=$?
echo "cleaned tmp"
} #CleanTmp
# vim: set ft=zsh ts=8 sw=4 tw=0 noet :

15
functions/_dotnet Normal file
View File

@ -0,0 +1,15 @@
#compdef dotnet
_dotnet()
{
local completions=("$(dotnet complete "$words")")
# If the completion list is empty, just continue with filename selection
if [ -z "$completions" ]
then
_arguments '*::arguments: _normal'
return
fi
# This is not a variable assigment, don't remove spaces!
_values = "${(ps:\n:)completions}"
}

8
functions/has Normal file
View File

@ -0,0 +1,8 @@
## Has function
has() {
Command=$1
[[ -z $Command ]] && return 1
command -v $Command > /dev/null 2>&1
}

9
functions/setTermTitle Normal file
View File

@ -0,0 +1,9 @@
setTermTitle() {
Terminal=$(echo $TERM | cut -d'-' -f1 )
[[ -z $1 ]] && Title="$Terminal" || Title="$Terminal - $1"
echo -e -n '\e]2;'"$Title"'\a'
}
# vim: set ft=zsh ts=8 sw=4 tw=0 noet :

25
functions/tempPersist Normal file
View File

@ -0,0 +1,25 @@
tempPersist() {
ARG=$1
if [ $# -eq 0 ]; then
if [[ -f ~/tmp/KEEPTMP ]]; then
echo "Temp is persistent"
else
echo "Temp will be Deleted"
fi
else
if [[ $ARG = "on" ]]; then
touch ~/tmp/KEEPTMP
echo "Temp is persistent"
elif [[ $ARG = "off" ]]; then
if [[ -f ~/tmp/KEEPTMP ]]; then
rm ~/tmp/KEEPTMP
fi
echo "Temp will be Deleted"
else
echo "on or off only"
fi
fi
}
# vim: set ft=zsh ts=8 sw=4 tw=0 noet :

11
greet Executable file → Normal file
View File

@ -1,13 +1,11 @@
#!/bin/sh
colours.sh
has colours.sh && colours.sh
echo '╭───────────╮'
echo '│ Welcome!! │'
echo '╰───────────╯'
date
if [ -d "$HOME/tmp" ]; then
if [ -f "$HOME/tmp/KEEPTMP" ] || [ -f "$HOME/.cleanupResult" ]; then
printf "\033[31m\e[1m\e[5mYou have files in your tmp directory\e[0m"
printf "\033[31m\e[1m\e[5mYou have files in your tmp directory\e[0m\n"
exa -alhT ~/tmp || tree ~/tmp
if [ -f "$HOME/.cleanupResult" ]; then
echo "ISSUE WAS:"
@ -15,5 +13,6 @@ if [ -d "$HOME/tmp" ]; then
fi
fi
fi
randomVerse
colours.sh
has randomVerse && randomVerse
has colours.sh && colours.sh
has glow && [ -f ~/TODO.md ] && glow ~/TODO.md

33
history Normal file
View File

@ -0,0 +1,33 @@
## History Configuration
[ ! -d $XDG_STATE_HOME/zsh ] && mkdir -p $XDG_STATE_HOME/zsh
## Options relating to saving history
export HISTSIZE=10000
export SAVEHIST=6000
export HISTFILE=$XDG_STATE_HOME/zsh/history
setopt extended_history ## Save timestamp in history
setopt inc_append_history_time ## incrementally append to history
## This option means that the history is updated by all shell sessions
## However it doesn't load them in like share_history does
setopt hist_ignore_dups ## Don't log the same thing twice
setopt hist_ignore_space ## Don't log things that start with space
setopt hist_reduce_blanks ## Compact unnecessary white-space
setopt hist_expire_dups_first ## Remove duplicates first (if any exist) when compacting history
setopt hist_save_no_dups ## Remove duplicates from history when writing
## Options relating to history use
setopt hist_find_no_dups ## Don't show duplicates when searching history
setopt hist_verify ## Dont' immediately execute expanded history `eg: sudo !!`
## This stops certain commands saving into the history file
export HISTORY_IGNORE='(cd(| *)|ls(| *)|pushd(| *)|popd(| *))'
## This hook goes even further and stops anything in the $HISTORY_IGNORE list from being
## added to the session local history (it still stays around in the up buffer until you run a new command afterwards)
zshaddhistory() {
emulate -L zsh
[[ ${1%%$'\n'} != ${~HISTORY_IGNORE} ]]
}
# vim: ft=zsh

11
hooks Normal file
View File

@ -0,0 +1,11 @@
#This file manages hooks so I can have multiple functions hooked the way I want
for file in $(find $ZDOTDIR/hooks.d -type f); do
source "$file"
done
add-zsh-hook -Uz chpwd _hook_glow
add-zsh-hook -Uz chpwd osc7
add-zsh-hook -Uz precmd termtitle
add-zsh-hook -Uz precmd osc113
# vim: ft=zsh

7
hooks.d/glow Normal file
View File

@ -0,0 +1,7 @@
## Load readme with glow (if available)
_hook_glow() {
has glow || return 0
find $PWD -maxdepth 1 -iname 'readme.md' -exec glow {} \;
}
## vim: ft=zsh

7
hooks.d/osc113 Normal file
View File

@ -0,0 +1,7 @@
## output OSC-113;A to tell foot how to jump between prompts
osc113() {
print -Pn "\e]133;A\e\\"
}
## vim: ft=zsh

13
hooks.d/osc7 Normal file
View File

@ -0,0 +1,13 @@
## output the current directory in the correct format for foot.
function osc7 {
local LC_ALL=C
export LC_ALL
setopt localoptions extendedglob
input=( ${(s::)PWD} )
uri=${(j::)input/(#b)([^A-Za-z0-9_.\!~*\'\(\)-\/])/%${(l:2::0:)$(([##16]#match))}}
print -n "\e]7;file://${HOSTNAME}${uri}\e\\"
}
# vim: ft=zsh

6
hooks.d/termtitle Normal file
View File

@ -0,0 +1,6 @@
## set terminal title
termtitle () {
setTermTitle "($(whoami)@$(hostname) $(pwd))"
}
## vim: ft=zsh

4
keyboard Executable file → Normal file
View File

@ -15,6 +15,8 @@ zle -N history-beginning-search-backward-end \
history-search-end
zle -N history-beginning-search-forward-end \
history-search-end
zle -N bracketed-paste bracketed-paste-magic
zle -N self-insert url-quote-magic
[[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line
@ -25,4 +27,4 @@ zle -N history-beginning-search-forward-end \
[[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-search
[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char
[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char
# vim: set ft=zsh ts=8 sw=4 tw=0 noet :
## vim: ft=zsh

20
prompt Executable file → Normal file
View File

@ -11,23 +11,25 @@ autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git
## Set icons for Staged and Unstaged Changes
zstyle ':vcs_info:git*' stagedstr ""
zstyle ':vcs_info:git*' unstagedstr ""
zstyle ':vcs_info:git*' stagedstr "%{%F{green%}%}󰄳 %{%f%}"
zstyle ':vcs_info:git*' unstagedstr "%{%F{red%}%}󰅙 %{%f%}"
## Enable check for changes (CPU-intensive)
## DISABLE THIS ON LOW POWER SYSTEMS
zstyle ':vcs_info:git*' check-for-changes true
## Set format for Repo Information
zstyle ':vcs_info:git*' formats "-(%s:שׂ %b %u%c)"
zstyle ':vcs_info:git*' formats "-(%{%F{203}%} %{%f%}%s:%{%F{2}%} %{%f%}%b %u%c)"
zstyle ':vcs_info:git*' actionformats "-(%{%F{203}%} %{%f%}%s:%{%F{2}%} %{%f%}%b %u%c)(%a)"
## set precmd to get vcs_info
## precmd runs before every prompt
precmd() {
## do precmd stuff
_vcsinfo() {
vcs_info
}
add-zsh-hook precmd _vcsinfo
PROMPT="$(setTermTitle "(%n@%m %~)")╭╼(%{%F{81}%}%n%{%F{245}%}@%{%F{206}%}%m %{%F{245}%}%~%{%F{259}%})─(%(?.😎.😞 %?))"$'\n'"╰┤"
RPROMPT='${vcs_info_msg_0_}'
# vim: set ft=zsh ts=2 sw=2 tw=0 noet :
PROMPT="╭╼(%{%F{81}%}%n%{%F{245}%}@%{%F{206}%}%m %{%F{245}%}%2~%{%F{259}%})─(%(?.😎.😞 %?))"$'\n'"╰┤"
export RPROMPT='${vcs_info_msg_0_}'
# vim: set ft=zsh:

32
theme Normal file
View File

@ -0,0 +1,32 @@
# Attempt to load pywal theme first (unless disabled)
if has 'wal' ; then
if [[ -z $NO_PYWAL ]]; then
if [[ -e $XDG_CACHE_HOME/wal/sequences ]]; then
cat $XDG_CACHE_HOME/wal/sequences && return
fi
wal -qnR && return
fi
fi
# Load theme.sh theme uses theme_history to set
if has 'theme.sh'; then
# Load the last set theme automatically
[ -e ~/.config/.theme_history ] && theme.sh "$(theme.sh -l|tail -n1)"
# Toggle between last set themes
last_theme() {
theme.sh "$(theme.sh -l | tail -n2 | head -n1)"
}
zle -N last_theme
bindkey '^o' last_theme
alias th='theme.sh -i'
alias thl='theme.sh --light -i'
alias thd='theme.sh --dark -i'
fi
# vim: ft=zsh

84
zshrc Executable file → Normal file
View File

@ -13,71 +13,85 @@ autoload -U calendar
autoload -U run-help
autoload -U +X compinit
autoload -U edit-command-line
autoload -U add-zsh-hook
autoload -U url-quote-magic
autoload -U bracketed-paste-magic
## zmodload Modules
zmodload zsh/complist
## Load my functions
fpath=( $ZDOTDIR/functions $fpath )
autoload CleanTmp
autoload setTermTitle
autoload tempPersist
autoload has
## check for and load .local/share/zsh/site-functions
[ -d "$HOME/.local/share/zsh/site-functions" ] && fpath=("$HOME/.local/share/zsh/site-functions" $fpath)
## Source Other files
source $HOME/.profile
source ${ZDOTDIR}/aliases
source ${ZDOTDIR}/dir_aliases
source ${ZDOTDIR}/prompt
source ${ZDOTDIR}/keyboard
source ${ZDOTDIR}/history
source ${ZDOTDIR}/hooks
source ${ZDOTDIR}/theme
## Source Functions
source ${ZDOTDIR}/functions/*
## Set option
setopt emacs ## Emacs style keybinds
setopt autocd ## Change to directory if given as command
setopt autopushd ## Automatically use pushd and stack
setopt correct ## Pick up on Spelling errors
setopt SHARE_HISTORY ## Share history across sessions
setopt hist_verify ## Edit Commands after expansion
## Set options
## NOTE: zsh ignores case and underscores
setopt vi ## Use vi style keybinds
setopt autoCd ## Change to directory if given as command
setopt autoPushd ## Automatically use pushd and stack
setopt chaseDots ## Remove contradictory .. from cd path (e.g cd foo/bar/.. -> cd foo)
setopt correct ## Pick up on Spelling errors
setopt extendedGlob ## Allow extended globbing (see man zshexpn)
setopt markDirs ## Add a trailing '/' to directories when globbing
setopt interactiveComments ## allow comments in interactive shells
setopt rmStarWait ## wait 10 seconds when confirming large deletes
## Configure History File
export HISTSIZE=10000
export SAVEHIST=$HISTSIZE
export HISTFILE=$HOME/.zhistory
## Configure Completions
zstyle ':completion:*' menu select ## use menu to select where possible
zstyle ':completion:*:descriptions' format '%U%B%d%b%u' ## better descriptions format
zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b' ## show when no matches
zstyle ':completion:*' completer _complete _match _approximate ## fuzzy match
zstyle ':completion:*:match:*' original only
zstyle -e ':completion:*:approximate:*' \
max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)' ## more errors in longer lines
zstyle ':completion:*:functions' ignored-patterns '_*' ## ignore completions for commands I dont have
zstyle ':completion:*' squeeze-slashes true ## remove trailing slashes
zstyle ':completion:*:cd:*' ignore-parents parent pwd ## don't complete parent dir
compinit
_comp_options+=(globdots)
source ${ZDOTDIR}/completion
## Configure command line editor
zle -N edit-command-line
bindkey "^X^E" edit-command-line
## Enable gpg-agent support
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
gpg-connect-agent /bye
export GPG_TTY=$(tty)
if [[ "$USE_GPG_AGENT" == "true" ]]; then
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
gpg-connect-agent /bye
export GPG_TTY=$(tty)
fi
## Load external stuff
## support for opam
test -r $HOME/.opam/opam-init/init.zsh && . $HOME/.opam/opam-init/init.zsh > /dev/null 2> /dev/null ||
##Configure for homebrew
if [[ -d "/home/linuxbrew" ]]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
if [[ -f ${XDG_DATA_HOME:="$HOME/.local/share"}/ghcup/env ]]; then
source ${XDG_DATA_HOME:="$HOME/.local/share"}/ghcup/env
fi
## Configure Plugins
export ZSH_AUTOSUGGEST_STRATEGY=(completion history) # suggest from completion then history
export ZSH_AUTOSUGGEST_USE_ASYNC=1 # make async for SPEED
export ZSH_AUTOSUGGEST_HISTORY_IGNORE='(cd|cp|tar|mv|ls|nvim|rm|rmdir|git) *'
## Load Plugins with ZshPlug
export ZSH_PLUG_plugins=( "zsh-users/zsh-autosuggestions" "zdharma-continuum/fast-syntax-highlighting" "MichaelAquilina/zsh-you-should-use" )
export ZSH_PLUG_plugins=( "zsh-users/zsh-autosuggestions" \
"zdharma-continuum/fast-syntax-highlighting" \
"jeffreytse/zsh-vi-mode" \
"MichaelAquilina/zsh-you-should-use"\
)
source $ZDOTDIR/ZshPlug/ZshPlug.zsh
[[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line
@ -92,4 +106,4 @@ source $ZDOTDIR/ZshPlug/ZshPlug.zsh
[[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" history-beginning-search-backward
[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" history-beginning-search-forward
$ZDOTDIR/greet
source $ZDOTDIR/greet