Grouping stuff

This commit is contained in:
2017-10-15 20:50:00 +02:00
parent b90cf92fb5
commit 832fa5ee30
30 changed files with 120 additions and 37 deletions

22
terminal/fish/config.fish Executable file
View File

@@ -0,0 +1,22 @@
set -x DOTFILES /Users/thomas/dotfiles
# The definition of $DOTFILES MUST be the first line of this file
# Don't change it!
if test "$SHLVL" -le 1
set -x PATH /usr/local/bin /usr/local/sbin $PATH
set -x PATH $DOTFILES/bin $PATH
if test -d $HOME/bin
set -x PATH $HOME/bin $PATH
end
set -x PATH . $PATH
set -x FISH_SETUP_PATH 'yes'
end
set -x LANG sv_SE.UTF-8
set -x LC_ALL sv_SE.UTF-8
set -x EDITOR nvim
alias v nvim
eval (python3 -m virtualfish)

View File

@@ -0,0 +1,31 @@
# This file is automatically generated by the fish.
# Do NOT edit it directly, your changes will be overwritten.
SET __fish_init_2_39_8:\x1d
SET __fish_init_2_3_0:\x1d
SET fish_color_autosuggestion:555\x1ebrblack
SET fish_color_cancel:\x2dr
SET fish_color_command:\x2d\x2dbold
SET fish_color_comment:red
SET fish_color_cwd:green
SET fish_color_cwd_root:red
SET fish_color_end:brmagenta
SET fish_color_error:brred
SET fish_color_escape:bryellow\x1e\x2d\x2dbold
SET fish_color_history_current:\x2d\x2dbold
SET fish_color_host:normal
SET fish_color_match:\x2d\x2dbackground\x3dbrblue
SET fish_color_normal:normal
SET fish_color_operator:bryellow
SET fish_color_param:cyan
SET fish_color_quote:yellow
SET fish_color_redirection:brblue
SET fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack
SET fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack
SET fish_color_user:brgreen
SET fish_color_valid_path:\x2d\x2dunderline
SET fish_greeting:Welcome\x20to\x20fish\x2c\x20the\x20friendly\x20interactive\x20shell
SET fish_key_bindings:fish_default_key_bindings
SET fish_pager_color_completion:\x1d
SET fish_pager_color_description:B3A06D\x1eyellow
SET fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
SET fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan

View File

@@ -0,0 +1,6 @@
function bubu --description="Update, upgrade and clean up homebrew packages"
brew update
and brew outdated
and brew upgrade
and brew cleanup
end

View File

@@ -0,0 +1,4 @@
function fish_greeting
end

View File

@@ -0,0 +1,29 @@
function fish_prompt
set -l status_copy $status
if set -q VIRTUAL_ENV
echo -sn "(" (basename "$VIRTUAL_ENV") ")"
end
# Hostname with unique color
set_color (hostname -s | md5 | cut -c-6)
echo -sn (hostname -s)
# A yellow separator
# The color of this could be used to signify something
set_color yellow
echo -sn ':'
# Contracted path to PWD
set_color normal
echo -sn (prompt_pwd)
# A green or red >, depending on exit status of last command
if test "$status_copy" -ne 0
set_color red
else
set_color green
end
echo -sn ' > '
end

View File

@@ -0,0 +1,34 @@
function fish_right_prompt
# Check if we are inside a version controlled directory (git only)
set -l ref (git symbolic-ref HEAD ^/dev/null)
if test -z $ref
return
end
# Check if any files have changes
git diff --no-ext-diff --quiet --exit-code ^/dev/null
or set -l dirty 'yes'
# Check if any files are staged
git diff-index --cached --quiet HEAD -- ^/dev/null
or set -l staged 'yes'
set_color normal
echo -sn '['
# Print branch name
# red if dirty
# yellow if staged
# green otherwise
if set -q staged
set_color yellow
else if set -q dirty
set_color red
else
set_color green
end
echo -sn (string replace refs/heads/ '' -- $ref)
set_color normal
echo -sn ']'
end

View File

@@ -0,0 +1,4 @@
function fish_user_key_bindings
bind \t try_subst
end

10
terminal/fish/functions/g.fish Executable file
View File

@@ -0,0 +1,10 @@
function g
# shortcut to git
# If no arguments are given, run git status and git l
if count $argv >/dev/null
git $argv
else
git status
git l -5
end
end

View File

@@ -0,0 +1,3 @@
function greb --description "Git rebase entire history, interactively"
git rebase --interactive (git rev-list --max-parents=0 HEAD)
end

View File

@@ -0,0 +1,40 @@
function man --description "Format and display the on-line manual pages"
# Work around the "builtin" manpage that everything symlinks to,
# by prepending our fish datadir to man. This also ensures that man gives fish's
# man pages priority, without having to put fish's bin directories first in $PATH
# My changes (Thomas Lovén)
# Add color to the man pager
#
# blink
set -lx LESS_TERMCAP_mb (set_color -o red)
# bold
set -lx LESS_TERMCAP_md (set_color -o purple)
set -lx LESS_TERMCAP_me (set_color normal)
# standout
set -lx LESS_TERMCAP_so (set_color -b blue) (set_color yellow)
set -lx LESS_TERMCAP_se (set_color normal)
# underline
set -lx LESS_TERMCAP_us (set_color -u green)
set -lx LESS_TERMCAP_ue (set_color normal)
set -l manpath
if set -q MANPATH
set manpath $MANPATH
else if command -qs manpath
set manpath (command manpath)
end
# Notice local exported copy of the variable.
set -lx MANPATH $manpath
set -l fish_manpath (dirname $__fish_datadir)/fish/man
if test -d "$fish_manpath" -a -n "$MANPATH"
set MANPATH $fish_manpath:$MANPATH
# Invoke man with this manpath, and we're done.
command man $argv
return
end
# If fish's man pages could not be found, just invoke man normally
command man $argv
end

View File

@@ -0,0 +1,4 @@
function mcd --description "Make directory and enter it"
mkdir -p $argv
and cd $argv
end

View File

@@ -0,0 +1,14 @@
function try_subst
# Use s/word/replacement<tab> to replace word with replacement
# in last command
commandline | read -l saved_commandline
set -l pattern '^s/..*/.*$'
if commandline -t | grep -E -q "$pattern"
commandline -tr (echo -n "$history[1]" | sed -e (commandline -t)/g)
else
commandline -f complete
end
end

32
terminal/fish/setup.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/env bash
source ${DOTFILES}/helpers.sh
function main()
{
local scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
print_info "Installing fish shell"
# Install fish shell
brewget fish
# Add to list of shells and set as default
if ! grep /usr/local/bin/fish < /etc/shells >/dev/null; then
echo /usr/local/bin/fish | sudo tee -a /etc/shells
chsh -s /usr/local/bin/fish
fi
# Install configuration files
makedir ${HOME}/.config
if ! head -n 1 ${scriptdir}/config.fish | grep ${DOTFILES} >/dev/null; then
sed -i '' "1s;.*;set -x DOTFILES ${DOTFILES};" ${scriptdir}/config.fish
fi
linkfile ${scriptdir} ${HOME}/.config/fish
print_ok "Fish shell installed"
}
main "$@"

21
terminal/kitty/setup.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
source ${DOTFILES}/helpers.sh
function main()
{
local scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
print_info "Installing kitty terminal"
# Copy kitty.app to /Applications
# cp ${KITTY_PATH} /Applications/.
# Install configuration file
linkfile ${scriptdir}/kitty.conf ${HOME}/Library/Preferences/kitty/kitty.conf
print_ok "Kitty terminal installed"
}
main "$@"

View File

@@ -4,21 +4,16 @@ source ${DOTFILES}/helpers.sh
function main()
{
print_info "Installing kitty terminal"
local scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
# Copy kitty.app to /Applications
# cp ${KITTY_PATH} /Applications/.
# Install configuration file
linkfile ${DOTFILES}/terminal/kitty.conf ${HOME}/Library/Preferences/kitty/kitty.conf
print_ok "Kitty terminal installed"
${scriptdir}/kitty/setup.sh
${scriptdir}/fish/setup.sh
print_info "Installing terminal applications"
brewget tmux
brewget neovim
print_ok "Terminal applications installed"
}
main "$@"