Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
376865abdf |
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,3 +1,2 @@
|
||||||
.zkbd/
|
.zkbd/
|
||||||
.zcompdump
|
.zcompdump
|
||||||
.zcalc_history
|
|
||||||
|
|
|
||||||
26
.zkbd/st-256color-:0
Normal file
26
.zkbd/st-256color-:0
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
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,202 +1,34 @@
|
||||||
# My ZSH configuration
|
# My ZSH config.
|
||||||
|
|
||||||
This repository has a fully loaded configuration for ZSH.
|
This is my personal ZSH config that I run on my laptop.
|
||||||
The configuration make opinionated choices based on my own desires for what
|
It works for what I want from a configured shell.
|
||||||
a shell should be like.
|
|
||||||
|
|
||||||
It's strongly advised that you write your own configuration instead of
|
I would recommend you actually create your own config before just using
|
||||||
just using this one. That way you can understand what you are doing and
|
mine since you will gain a proper understanding of how ZSH works and just
|
||||||
maybe gain a better appreciation for the shell and its features.
|
what it can do.
|
||||||
|
|
||||||
The configuration is broken down into modules where possible, this
|
I have attempted to organise my config into a series of files that each
|
||||||
makes it easier to hack on.
|
perform a specific task, that way it is easier for me to change small
|
||||||
|
sections as the need arises.
|
||||||
|
|
||||||
## Usage
|
## How to use
|
||||||
|
|
||||||
Clone this repository to `~/.config/zsh`
|
If you really really want to just blindly copy me then you will need to
|
||||||
|
clone this repository to `~/.config/zsh`
|
||||||
|
|
||||||
Inside of that directory run:
|
Inside of the cloned repository run:
|
||||||
```sh
|
```sh
|
||||||
git submodule init
|
git submodule init
|
||||||
git submodule update
|
git submodule update
|
||||||
```
|
```
|
||||||
This will pull my plug-in manager `ZshPlug`.
|
This will pull in the latest version of my plugin manager.
|
||||||
|
|
||||||
And then add the following into `~/.zshenv`:
|
And then add the following into your `~/.profile`:
|
||||||
```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.
|
||||||
|
|
||||||
### Important note
|
If anything goes wrong feel free to open an issue. But this is entirely a
|
||||||
It is possible that your system might not be happy with this.
|
personal project for my own use, so don't expect anything.
|
||||||
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 592295a85a89a27abe7c8424304c676630e80e58
|
Subproject commit 3ddf1405d81861f1af4455e3716abd230b531a3f
|
||||||
46
aliases
Normal file → Executable file
46
aliases
Normal file → Executable file
|
|
@ -34,26 +34,21 @@
|
||||||
|
|
||||||
## Use Exa instead of ls
|
## Use Exa instead of ls
|
||||||
## REQUIRES NERD FONT
|
## REQUIRES NERD FONT
|
||||||
has eza && EXA=eza || EXA=exa
|
alias ls='exa --icons --group-directories-first'
|
||||||
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
|
||||||
has xdg-open && alias xopen='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)
|
||||||
has scriptedit && alias se='scriptedit'
|
alias se='scriptedit'
|
||||||
|
|
||||||
## YouTube downloader
|
## YouTube downloader
|
||||||
if has youtube-dl ; then
|
alias yt='youtube-dl'
|
||||||
alias yt='youtube-dl'
|
alias yta='youtube-dl --ignore-config --add-metadata --ignore-errors --extract-audio --format "bestaudio/best"'
|
||||||
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'
|
||||||
|
|
@ -67,38 +62,17 @@ alias grep='grep --color=auto'
|
||||||
alias ip='ip --color=auto'
|
alias ip='ip --color=auto'
|
||||||
|
|
||||||
## Open Vimwiki
|
## Open Vimwiki
|
||||||
has nvim && alias vw='nvim -c VimwikiIndex'
|
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
|
|
||||||
|
|
||||||
if [[ -n $VIM ]]; then
|
alias -s tex=nvim
|
||||||
alias -s tex=$VIM
|
alias -s html=nvim
|
||||||
alias -s html=$VIM
|
alias -s pdf=zathura
|
||||||
alias -s md=$VIM
|
alias -s md=nvim
|
||||||
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
65
completion
|
|
@ -1,65 +0,0 @@
|
||||||
############
|
|
||||||
# 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
Normal file → Executable file
3
dir_aliases
Normal file → Executable file
|
|
@ -6,5 +6,4 @@ 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="${Z_PROJECT_DIR:-$HOME/Projects}"
|
hash -d pr="$HOME/Projects"
|
||||||
# vim: ft=zsh
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
#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}"
|
|
||||||
}
|
|
||||||
|
|
@ -22,4 +22,3 @@ status=$?
|
||||||
|
|
||||||
echo "cleaned tmp"
|
echo "cleaned tmp"
|
||||||
} #CleanTmp
|
} #CleanTmp
|
||||||
# vim: set ft=zsh ts=8 sw=4 tw=0 noet :
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
## Has function
|
|
||||||
|
|
||||||
has() {
|
|
||||||
Command=$1
|
|
||||||
[[ -z $Command ]] && return 1
|
|
||||||
|
|
||||||
command -v $Command > /dev/null 2>&1
|
|
||||||
}
|
|
||||||
12
functions/hooks
Executable file
12
functions/hooks
Executable file
|
|
@ -0,0 +1,12 @@
|
||||||
|
Pre_Greet_Hook() {
|
||||||
|
[ -z $PRE_GREET ]
|
||||||
|
for cmd in "$PRE_GREET"; do
|
||||||
|
"$cmd"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
Post_Greet_Hook() {
|
||||||
|
[ -z $PRE_GREET ]
|
||||||
|
for cmd in "$POST_GREET"; do
|
||||||
|
"$cmd"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
|
|
||||||
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 :
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
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
Normal file → Executable file
11
greet
Normal file → Executable file
|
|
@ -1,11 +1,13 @@
|
||||||
has colours.sh && colours.sh
|
#!/bin/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\n"
|
printf "\033[31m\e[1m\e[5mYou have files in your tmp directory\e[0m"
|
||||||
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:"
|
||||||
|
|
@ -13,6 +15,5 @@ if [ -d "$HOME/tmp" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
has randomVerse && randomVerse
|
randomVerse
|
||||||
has colours.sh && colours.sh
|
colours.sh
|
||||||
has glow && [ -f ~/TODO.md ] && glow ~/TODO.md
|
|
||||||
|
|
|
||||||
33
history
33
history
|
|
@ -1,33 +0,0 @@
|
||||||
## 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
11
hooks
|
|
@ -1,11 +0,0 @@
|
||||||
#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
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
## Load readme with glow (if available)
|
|
||||||
_hook_glow() {
|
|
||||||
has glow || return 0
|
|
||||||
find $PWD -maxdepth 1 -iname 'readme.md' -exec glow {} \;
|
|
||||||
}
|
|
||||||
|
|
||||||
## vim: ft=zsh
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
## 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
13
hooks.d/osc7
|
|
@ -1,13 +0,0 @@
|
||||||
## 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
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
## set terminal title
|
|
||||||
termtitle () {
|
|
||||||
setTermTitle "($(whoami)@$(hostname) $(pwd))"
|
|
||||||
}
|
|
||||||
|
|
||||||
## vim: ft=zsh
|
|
||||||
4
keyboard
Normal file → Executable file
4
keyboard
Normal file → Executable file
|
|
@ -15,8 +15,6 @@ 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
|
||||||
|
|
@ -27,4 +25,4 @@ zle -N self-insert url-quote-magic
|
||||||
[[ -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: ft=zsh
|
# vim: set ft=zsh ts=8 sw=4 tw=0 noet :
|
||||||
|
|
|
||||||
20
prompt
Normal file → Executable file
20
prompt
Normal file → Executable file
|
|
@ -11,25 +11,23 @@ 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 "%{%F{green%}%} %{%f%}"
|
zstyle ':vcs_info:git*' stagedstr "✅"
|
||||||
zstyle ':vcs_info:git*' unstagedstr "%{%F{red%}%} %{%f%}"
|
zstyle ':vcs_info:git*' unstagedstr "⛔"
|
||||||
|
|
||||||
## 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 "-(%{%F{203}%} %{%f%}%s:%{%F{2}%} %{%f%}%b %u%c)"
|
zstyle ':vcs_info:git*' formats "-(%s:שׂ %b %u%c)"
|
||||||
zstyle ':vcs_info:git*' actionformats "-(%{%F{203}%} %{%f%}%s:%{%F{2}%} %{%f%}%b %u%c)(%a)"
|
|
||||||
|
|
||||||
## do precmd stuff
|
## set precmd to get vcs_info
|
||||||
_vcsinfo() {
|
## precmd runs before every prompt
|
||||||
|
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_}'
|
||||||
|
|
||||||
PROMPT="╭╼(%{%F{81}%}%n%{%F{245}%}@%{%F{206}%}%m %{%F{245}%}%2~%{%F{259}%})─(%(?.😎.😞 %?))"$'\n'"╰┤"
|
# vim: set ft=zsh ts=2 sw=2 tw=0 noet :
|
||||||
export RPROMPT='${vcs_info_msg_0_}'
|
|
||||||
|
|
||||||
# vim: set ft=zsh:
|
|
||||||
|
|
|
||||||
32
theme
32
theme
|
|
@ -1,32 +0,0 @@
|
||||||
# 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
Normal file → Executable file
82
zshrc
Normal file → Executable file
|
|
@ -13,85 +13,71 @@ 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 options
|
## Set option
|
||||||
## NOTE: zsh ignores case and underscores
|
setopt emacs ## Emacs style keybinds
|
||||||
setopt vi ## Use vi style keybinds
|
setopt autocd ## Change to directory if given as command
|
||||||
setopt autoCd ## Change to directory if given as command
|
setopt autopushd ## Automatically use pushd and stack
|
||||||
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 extendedGlob ## Allow extended globbing (see man zshexpn)
|
setopt SHARE_HISTORY ## Share history across sessions
|
||||||
setopt markDirs ## Add a trailing '/' to directories when globbing
|
setopt hist_verify ## Edit Commands after expansion
|
||||||
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
|
||||||
|
|
||||||
source ${ZDOTDIR}/completion
|
compinit
|
||||||
|
_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
|
||||||
if [[ "$USE_GPG_AGENT" == "true" ]]; then
|
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
|
||||||
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
|
gpgconf --launch gpg-agent
|
||||||
gpgconf --launch gpg-agent
|
gpg-connect-agent /bye
|
||||||
gpg-connect-agent /bye
|
export GPG_TTY=$(tty)
|
||||||
export GPG_TTY=$(tty)
|
|
||||||
fi
|
|
||||||
|
|
||||||
## Load external stuff
|
## Load external stuff
|
||||||
|
|
||||||
##Configure for homebrew
|
## support for opam
|
||||||
if [[ -d "/home/linuxbrew" ]]; then
|
test -r $HOME/.opam/opam-init/init.zsh && . $HOME/.opam/opam-init/init.zsh > /dev/null 2> /dev/null ||
|
||||||
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" \
|
export ZSH_PLUG_plugins=( "zsh-users/zsh-autosuggestions" "zdharma-continuum/fast-syntax-highlighting" "MichaelAquilina/zsh-you-should-use" )
|
||||||
"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
|
||||||
|
|
@ -106,4 +92,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
|
||||||
|
|
||||||
source $ZDOTDIR/greet
|
$ZDOTDIR/greet
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user