profiles: init develop

setup zshrc
This commit is contained in:
Timothy DeHerrera 2019-12-14 21:37:46 -07:00
parent 96e530e2cb
commit 6b26ef84a8
No known key found for this signature in database
GPG key ID: 8985725DB5B0C122
8 changed files with 315 additions and 3 deletions

View file

@ -3,7 +3,9 @@ let
inherit (builtins) readFile;
in
{
imports = [];
imports = [
../profiles/develop
];
boot.loader.systemd-boot = {

View file

@ -0,0 +1,45 @@
{ stdenv, fetchFromGitHub, openssl, pkgconfig, rustPlatform }:
with rustPlatform;
let
inherit (builtins)
readFile
toFile
;
init = toFile "init.sh" "${readFile ./init.sh}";
in
buildRustPackage rec {
pname = "purs";
version = "0.1.0";
srcs = fetchFromGitHub {
owner = "xcambar";
repo = "purs";
rev = "09ed252625b691841b0043699fd4ab590edabe29";
hash = "sha256-QwkbqNROksRo+QmRrgkWuoPzPb2XBwavEtlR9oqAXDQ=";
};
buildInputs = [
openssl
pkgconfig
];
cargoSha256 = "sha256-vyO2JRRA7FCNVmIeN1xybQXkdgoHbhMGT2AhUJEnp0s=";
postInstall = ''
mkdir -p $out/share/zsh/plugins/purs
substitute ${init} $out/share/zsh/plugins/purs/purs.zsh \
--subst-var-by PURS $out
'';
meta = with stdenv.lib; {
description = "A Pure-inspired prompt in Rust";
homepage = https://github.com/xcambar/purs;
maintainers = [ maintainers.nrdxp ];
license = licenses.mit;
inherit version;
};
}

View file

@ -0,0 +1,13 @@
function zle-line-init zle-keymap-select {
PROMPT=`@PURS@/bin/purs prompt -k "$KEYMAP" -r "$?" --venv "${${VIRTUAL_ENV:t}%-*}"`
zle reset-prompt
}
zle -N zle-line-init
zle -N zle-keymap-select
autoload -Uz add-zsh-hook
function _prompt_purs_precmd() {
@PURS@/bin/purs precmd
}
add-zsh-hook precmd _prompt_purs_precmd

View file

@ -1,4 +1,10 @@
{ config, lib, pkgs, ... }:
let
inherit (lib)
fileContents
;
in
{
imports = [
@ -45,6 +51,10 @@
"...." = "cd ../../..";
"....." = "cd ../../../..";
# grep
grep = "rg";
gi = "grep -i";
# internet ip
myip = "dig +short myip.opendns.com @208.67.222.222 2>&1";
@ -127,8 +137,7 @@
users = {
mutableUsers = false;
users.root.hashedPassword = readFile
../secrets/root;
users.root.hashedPassword = fileContents ../secrets/root;
};
}

View file

@ -0,0 +1,31 @@
{ pkgs, ... }:
{
imports = [
./zsh
];
environment.sessionVariables = {
LESS = "-iFJMRWX -z-4 -x4";
LESSOPEN = "|${pkgs.lesspipe}/bin/lesspipe.sh %s";
};
environment.systemPackages = with pkgs; [
bzip2
git-crypt
htop
less
gzip
file
lrzip
ncdu
p7zip
tokei
tig
unrar
unzip
wget
xz
];
programs.thefuck.enable = true;
}

View file

@ -0,0 +1 @@
while read line; do line=${(Q)line}; [[ -d $line ]] && echo $line; done < /home/nrd/.cache/zsh-cdr/recent-dirs

View file

@ -0,0 +1,100 @@
{ lib, pkgs, ... }:
let
inherit (builtins)
concatStringsSep
;
inherit (lib)
fileContents
;
in
{
users.defaultUserShell = pkgs.zsh;
environment = {
sessionVariables = let
fd = "${pkgs.fd}/bin/fd -H";
in
{
BAT_PAGER = "less";
SKIM_ALT_C_COMMAND =
"while read line; do "
+ "line=\"'\${(Q)line}'\"; [[ -d \"'$line'\" ]] && echo \"'$line'\"; "
+ "done < $HOME/.cache/zsh-cdr/recent-dirs";
SKIM_DEFAULT_COMMAND = fd;
SKIM_CTRL_T_COMMAND = fd;
};
shellAliases = {
cat = "${pkgs.bat}/bin/bat";
df = "df -h";
du = "du -h";
ls = "${pkgs.exa}/bin/exa";
l = "ls -lh --git";
la = "l -a";
rz = "exec zsh";
};
systemPackages = with pkgs; [
direnv
gitAndTools.hub
skim
zsh-completions
];
};
nixpkgs.overlays = let
purs = self: super:
{ purs = super.callPackage ../../../pkgs/shells/zsh/purs {}; };
in
[ purs ];
programs.zsh = {
enable = true;
promptInit = ''
source ${pkgs.purs}/share/zsh/plugins/purs/purs.zsh
'';
interactiveShellInit = let
zshrc = fileContents ./zshrc;
paths = with pkgs; [
"${skim}/share/skim/completion.zsh"
"${oh-my-zsh}/share/oh-my-zsh/plugins/sudo/sudo.plugin.zsh"
"${oh-my-zsh}/share/oh-my-zsh/plugins/extract/extract.plugin.zsh"
"${zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
"${zsh-history-substring-search}/share/zsh-history-substring-search/zsh-history-substring-search.zsh"
];
source = map
(source: "source " + source)
paths;
plugins = concatStringsSep "\n"
(
[
"${pkgs.any-nix-shell}/bin/any-nix-shell zsh --info-right | source /dev/stdin"
] ++
source
);
in
''
${plugins}
${zshrc}
source ${pkgs.skim}/share/skim/key-bindings.zsh
'';
};
}

111
profiles/develop/zsh/zshrc Normal file
View file

@ -0,0 +1,111 @@
hash -d \
nixos=/etc/nixos \
dl=~/Downloads \
git=~/git
hash -d \
github=~git/github.com \
gitlab=~git/gitlab.com
# hub setup
eval $(hub alias -s)
# Zsh options
setopt extendedglob
setopt incappendhistory
setopt sharehistory
setopt histignoredups
setopt histreduceblanks
setopt histignorespace
setopt histallowclobber
setopt autocd
setopt cdablevars
setopt nomultios
setopt pushdignoredups
setopt autocontinue
setopt promptsubst
# Environment
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=$HOME/.history
DIRSTACKSIZE=5
# user defined functions
if [[ -d $HOME/.zfunctions ]]; then
typeset -U fpath
fpath=($HOME/.zfunctions $fpath)
for file in $HOME/.zfunctions/*; do
autoload -Uz $file
done
fi
# source local config not synced to git repo
if [[ -f $HOME/.zshlocal ]]; then
. $HOME/.zshlocal
fi
# create local zshrc if it does not exist
[[ -f $HOME/.zshrc ]] \
|| printf "#" > $HOME/.zshrc
# history substring search keybinds
bindkey '^[OA' history-substring-search-up
bindkey '^[OB' history-substring-search-down
bindkey -M vicmd 'k' history-substring-search-up
bindkey -M vicmd 'j' history-substring-search-down
zle -N zle-line-init
# if in tmux launch skim in tmux pane
[[ ${+TMUX} == 1 ]] \
&& SKIM_TMUX=1
#load compinit
autoload -Uz compinit
typeset -i updated_at=$(date +'%j' -r ~/.zcompdump ||
stat -f '%Sm' -t '%j' ~/.zcompdump)
if [ $(date +'%j') != $updated_at ]; then
compinit
else
compinit -C
fi
# Case insens only when no case match; after all completions loaded
zstyle ':completion:*' matcher-list \
"" 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
# Auto rehash for new binaries
zstyle ':completion:*' rehash true
# Key binds
bindkey "jj" vi-cmd-mode
bindkey -v '^?' backward-delete-char
# keep shell state frozen
ttyctl -f
# colorful man pages
man () {
LESS_TERMCAP_md=$'\e[01;31m' \
LESS_TERMCAP_me=$'\e[0m' \
LESS_TERMCAP_se=$'\e[0m' \
LESS_TERMCAP_so=$'\e[01;44;33m' \
LESS_TERMCAP_ue=$'\e[0m' \
LESS_TERMCAP_us=$'\e[01;32m' \
man "$@"
}
# pipe rg into less with colors
rgl () {
rg --color=always $@ | less
}
# mkdir & cd to it
function mcd() {
mkdir -p "$1" && cd "$1";
}
# direnv setup
eval "$(direnv hook zsh)"