Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 16201be750 | |||
| 1f4cc35078 | |||
| 9392c2eb19 | |||
| 169cf0c209 | |||
| 0100d1c64f | |||
| 654a2ad327 | |||
| 2ad568db03 | |||
| cd0ec0c563 | |||
| 6a7f432e33 | |||
| 1a18c13306 | |||
| 08539a0de6 | |||
| 9da7b6babf | |||
| 43e3ce2765 | |||
| c2f60ba7fd | |||
| ef86f64945 | |||
| 7ad661267e | |||
| a79e9e988f | |||
|
|
d99aa241fe | ||
|
|
c46372add1 | ||
|
|
a91c9a530e | ||
|
|
91252d1b54 | ||
|
|
ab222a30c7 | ||
|
|
5d1484881e | ||
|
|
a029d2f348 | ||
|
|
9ff7659ada | ||
|
|
4970349c55 | ||
|
|
70822b11da | ||
|
|
acea2aed2c | ||
|
|
bbf21d3b21 |
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
||||||
.zkbd/
|
.zkbd/
|
||||||
.zcompdump
|
.zcompdump
|
||||||
|
.zcalc_history
|
||||||
|
|
|
||||||
|
|
@ -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
204
Readme.md
|
|
@ -1,34 +1,202 @@
|
||||||
# My ZSH config.
|
# My ZSH configuration
|
||||||
|
|
||||||
This is my personal ZSH config that I run on my laptop.
|
This repository has a fully loaded configuration for ZSH.
|
||||||
It works for what I want from a configured shell.
|
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
|
It's strongly advised that you write your own configuration instead of
|
||||||
mine since you will gain a proper understanding of how ZSH works and just
|
just using this one. That way you can understand what you are doing and
|
||||||
what it can do.
|
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
|
The configuration is broken down into modules where possible, this
|
||||||
perform a specific task, that way it is easier for me to change small
|
makes it easier to hack on.
|
||||||
sections as the need arises.
|
|
||||||
|
|
||||||
## 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
|
```sh
|
||||||
git submodule init
|
git submodule init
|
||||||
git submodule update
|
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
|
```sh
|
||||||
export ZDOTDIR="${XDG_CONFIG_HOME:-$HOME/.config}/zsh"
|
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
|
### Important note
|
||||||
personal project for my own use, so don't expect anything.
|
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.
|
||||||
|
|
|
||||||
2
ZshPlug
2
ZshPlug
|
|
@ -1 +1 @@
|
||||||
Subproject commit 3ddf1405d81861f1af4455e3716abd230b531a3f
|
Subproject commit 592295a85a89a27abe7c8424304c676630e80e58
|
||||||
46
aliases
Executable file → Normal file
46
aliases
Executable file → Normal file
|
|
@ -34,21 +34,26 @@
|
||||||
|
|
||||||
## Use Exa instead of ls
|
## Use Exa instead of ls
|
||||||
## REQUIRES NERD FONT
|
## 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
|
## Shorten xdg-open
|
||||||
alias xopen='xdg-open'
|
has xdg-open && alias xopen='xdg-open'
|
||||||
|
|
||||||
## cls Clear Screen run ls
|
## cls Clear Screen run ls
|
||||||
alias cls='clear; ls'
|
alias cls='clear; ls'
|
||||||
|
|
||||||
## Shorten scriptedit
|
## Shorten scriptedit
|
||||||
## REQUIRES scriptedit (Script)
|
## REQUIRES scriptedit (Script)
|
||||||
alias se='scriptedit'
|
has scriptedit && alias se='scriptedit'
|
||||||
|
|
||||||
## YouTube downloader
|
## YouTube downloader
|
||||||
alias yt='youtube-dl'
|
if has youtube-dl ; then
|
||||||
alias yta='youtube-dl --ignore-config --add-metadata --ignore-errors --extract-audio --format "bestaudio/best"'
|
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'
|
alias cp='cp --interactive --verbose'
|
||||||
|
|
@ -62,17 +67,38 @@ alias grep='grep --color=auto'
|
||||||
alias ip='ip --color=auto'
|
alias ip='ip --color=auto'
|
||||||
|
|
||||||
## Open Vimwiki
|
## 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 #
|
# FileType Associations #
|
||||||
# extension=program #
|
# 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
|
if [[ -n $VIM ]]; then
|
||||||
alias -s html=nvim
|
alias -s tex=$VIM
|
||||||
alias -s pdf=zathura
|
alias -s html=$VIM
|
||||||
alias -s md=nvim
|
alias -s md=$VIM
|
||||||
|
fi
|
||||||
|
unset $VIM
|
||||||
|
|
||||||
|
has zathura && alias -s pdf=zathura
|
||||||
|
|
||||||
|
|
||||||
# vim: set ft=zsh ts=2 sw=2 tw=0 noet :
|
# vim: set ft=zsh ts=2 sw=2 tw=0 noet :
|
||||||
|
|
|
||||||
65
completion
Normal file
65
completion
Normal 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
3
dir_aliases
Executable file → Normal file
|
|
@ -6,4 +6,5 @@ hash -d dx="$HOME/Documents"
|
||||||
hash -d dl="$HOME/Downloads"
|
hash -d dl="$HOME/Downloads"
|
||||||
hash -d cn="${XDG_CONFIG_HOME:-$HOME/.config}"
|
hash -d cn="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||||
hash -d px="$HOME/Pictures"
|
hash -d px="$HOME/Pictures"
|
||||||
hash -d pr="$HOME/Projects"
|
hash -d pr="${Z_PROJECT_DIR:-$HOME/Projects}"
|
||||||
|
# vim: ft=zsh
|
||||||
|
|
|
||||||
|
|
@ -22,3 +22,4 @@ status=$?
|
||||||
|
|
||||||
echo "cleaned tmp"
|
echo "cleaned tmp"
|
||||||
} #CleanTmp
|
} #CleanTmp
|
||||||
|
# vim: set ft=zsh ts=8 sw=4 tw=0 noet :
|
||||||
15
functions/_dotnet
Normal file
15
functions/_dotnet
Normal 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
8
functions/has
Normal 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
9
functions/setTermTitle
Normal 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
25
functions/tempPersist
Normal 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
11
greet
Executable file → Normal file
|
|
@ -1,13 +1,11 @@
|
||||||
#!/bin/sh
|
has colours.sh && colours.sh
|
||||||
|
|
||||||
colours.sh
|
|
||||||
echo '╭───────────╮'
|
echo '╭───────────╮'
|
||||||
echo '│ Welcome!! │'
|
echo '│ Welcome!! │'
|
||||||
echo '╰───────────╯'
|
echo '╰───────────╯'
|
||||||
date
|
date
|
||||||
if [ -d "$HOME/tmp" ]; then
|
if [ -d "$HOME/tmp" ]; then
|
||||||
if [ -f "$HOME/tmp/KEEPTMP" ] || [ -f "$HOME/.cleanupResult" ]; 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
|
exa -alhT ~/tmp || tree ~/tmp
|
||||||
if [ -f "$HOME/.cleanupResult" ]; then
|
if [ -f "$HOME/.cleanupResult" ]; then
|
||||||
echo "ISSUE WAS:"
|
echo "ISSUE WAS:"
|
||||||
|
|
@ -15,5 +13,6 @@ if [ -d "$HOME/tmp" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
randomVerse
|
has randomVerse && randomVerse
|
||||||
colours.sh
|
has colours.sh && colours.sh
|
||||||
|
has glow && [ -f ~/TODO.md ] && glow ~/TODO.md
|
||||||
|
|
|
||||||
33
history
Normal file
33
history
Normal 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
11
hooks
Normal 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
7
hooks.d/glow
Normal 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
7
hooks.d/osc113
Normal 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
13
hooks.d/osc7
Normal 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
6
hooks.d/termtitle
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
## set terminal title
|
||||||
|
termtitle () {
|
||||||
|
setTermTitle "($(whoami)@$(hostname) $(pwd))"
|
||||||
|
}
|
||||||
|
|
||||||
|
## vim: ft=zsh
|
||||||
4
keyboard
Executable file → Normal file
4
keyboard
Executable file → Normal file
|
|
@ -15,6 +15,8 @@ zle -N history-beginning-search-backward-end \
|
||||||
history-search-end
|
history-search-end
|
||||||
zle -N history-beginning-search-forward-end \
|
zle -N history-beginning-search-forward-end \
|
||||||
history-search-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[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line
|
||||||
[[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-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[Down]}" ]] && bindkey "${key[Down]}" down-line-or-search
|
||||||
[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char
|
[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char
|
||||||
[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-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
20
prompt
Executable file → Normal file
|
|
@ -11,23 +11,25 @@ autoload -Uz vcs_info
|
||||||
zstyle ':vcs_info:*' enable git
|
zstyle ':vcs_info:*' enable git
|
||||||
|
|
||||||
## Set icons for Staged and Unstaged Changes
|
## Set icons for Staged and Unstaged Changes
|
||||||
zstyle ':vcs_info:git*' stagedstr "✅"
|
zstyle ':vcs_info:git*' stagedstr "%{%F{green%}%} %{%f%}"
|
||||||
zstyle ':vcs_info:git*' unstagedstr "⛔"
|
zstyle ':vcs_info:git*' unstagedstr "%{%F{red%}%} %{%f%}"
|
||||||
|
|
||||||
## Enable check for changes (CPU-intensive)
|
## Enable check for changes (CPU-intensive)
|
||||||
## DISABLE THIS ON LOW POWER SYSTEMS
|
## DISABLE THIS ON LOW POWER SYSTEMS
|
||||||
zstyle ':vcs_info:git*' check-for-changes true
|
zstyle ':vcs_info:git*' check-for-changes true
|
||||||
|
|
||||||
## Set format for Repo Information
|
## 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
|
## do precmd stuff
|
||||||
## precmd runs before every prompt
|
_vcsinfo() {
|
||||||
precmd() {
|
|
||||||
vcs_info
|
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
32
theme
Normal 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
|
||||||
82
zshrc
Executable file → Normal file
82
zshrc
Executable file → Normal file
|
|
@ -13,71 +13,85 @@ autoload -U calendar
|
||||||
autoload -U run-help
|
autoload -U run-help
|
||||||
autoload -U +X compinit
|
autoload -U +X compinit
|
||||||
autoload -U edit-command-line
|
autoload -U edit-command-line
|
||||||
|
autoload -U add-zsh-hook
|
||||||
|
autoload -U url-quote-magic
|
||||||
|
autoload -U bracketed-paste-magic
|
||||||
|
|
||||||
## zmodload Modules
|
## zmodload Modules
|
||||||
zmodload zsh/complist
|
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 Other files
|
||||||
source $HOME/.profile
|
|
||||||
source ${ZDOTDIR}/aliases
|
source ${ZDOTDIR}/aliases
|
||||||
source ${ZDOTDIR}/dir_aliases
|
source ${ZDOTDIR}/dir_aliases
|
||||||
source ${ZDOTDIR}/prompt
|
source ${ZDOTDIR}/prompt
|
||||||
source ${ZDOTDIR}/keyboard
|
source ${ZDOTDIR}/keyboard
|
||||||
|
source ${ZDOTDIR}/history
|
||||||
|
source ${ZDOTDIR}/hooks
|
||||||
|
source ${ZDOTDIR}/theme
|
||||||
|
|
||||||
## Source Functions
|
|
||||||
source ${ZDOTDIR}/functions/*
|
|
||||||
|
|
||||||
## Set option
|
## Set options
|
||||||
setopt emacs ## Emacs style keybinds
|
## NOTE: zsh ignores case and underscores
|
||||||
setopt autocd ## Change to directory if given as command
|
setopt vi ## Use vi style keybinds
|
||||||
setopt autopushd ## Automatically use pushd and stack
|
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 correct ## Pick up on Spelling errors
|
||||||
setopt SHARE_HISTORY ## Share history across sessions
|
setopt extendedGlob ## Allow extended globbing (see man zshexpn)
|
||||||
setopt hist_verify ## Edit Commands after expansion
|
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
|
source ${ZDOTDIR}/completion
|
||||||
_comp_options+=(globdots)
|
|
||||||
|
|
||||||
## Configure command line editor
|
## Configure command line editor
|
||||||
zle -N edit-command-line
|
zle -N edit-command-line
|
||||||
bindkey "^X^E" edit-command-line
|
bindkey "^X^E" edit-command-line
|
||||||
|
|
||||||
## Enable gpg-agent support
|
## Enable gpg-agent support
|
||||||
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
|
if [[ "$USE_GPG_AGENT" == "true" ]]; then
|
||||||
gpgconf --launch gpg-agent
|
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
|
||||||
gpg-connect-agent /bye
|
gpgconf --launch gpg-agent
|
||||||
export GPG_TTY=$(tty)
|
gpg-connect-agent /bye
|
||||||
|
export GPG_TTY=$(tty)
|
||||||
|
fi
|
||||||
|
|
||||||
## Load external stuff
|
## Load external stuff
|
||||||
|
|
||||||
## support for opam
|
##Configure for homebrew
|
||||||
test -r $HOME/.opam/opam-init/init.zsh && . $HOME/.opam/opam-init/init.zsh > /dev/null 2> /dev/null ||
|
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
|
## Configure Plugins
|
||||||
export ZSH_AUTOSUGGEST_STRATEGY=(completion history) # suggest from completion then history
|
export ZSH_AUTOSUGGEST_STRATEGY=(completion history) # suggest from completion then history
|
||||||
export ZSH_AUTOSUGGEST_USE_ASYNC=1 # make async for SPEED
|
export ZSH_AUTOSUGGEST_USE_ASYNC=1 # make async for SPEED
|
||||||
export ZSH_AUTOSUGGEST_HISTORY_IGNORE='(cd|cp|tar|mv|ls|nvim|rm|rmdir|git) *'
|
export ZSH_AUTOSUGGEST_HISTORY_IGNORE='(cd|cp|tar|mv|ls|nvim|rm|rmdir|git) *'
|
||||||
|
|
||||||
|
|
||||||
## Load Plugins with ZshPlug
|
## 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
|
source $ZDOTDIR/ZshPlug/ZshPlug.zsh
|
||||||
|
|
||||||
[[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line
|
[[ -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[PageUp]}" ]] && bindkey "${key[PageUp]}" history-beginning-search-backward
|
||||||
[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" history-beginning-search-forward
|
[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" history-beginning-search-forward
|
||||||
|
|
||||||
$ZDOTDIR/greet
|
source $ZDOTDIR/greet
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user