From 70757528fc47df1ec43234c29dc9a8274cd612f1 Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Fri, 7 Sep 2018 14:15:59 -0400 Subject: [PATCH] Add other fish functions This commit adds fish support for the other functions I used to use in zsh. Since my dotfiles are now separated by environment, it's easy to see which environment depends on which dotfiles, instead of stowing them one by one based on software name. --- dots/bspwm/.config/fish/functions/1080p.fish | 7 ++++++ dots/bspwm/.config/fish/functions/4k.fish | 24 ++++++++++++++++++++ dots/common/.config/fish/functions/lab.fish | 11 +++++++++ 3 files changed, 42 insertions(+) create mode 100644 dots/bspwm/.config/fish/functions/1080p.fish create mode 100644 dots/bspwm/.config/fish/functions/4k.fish create mode 100644 dots/common/.config/fish/functions/lab.fish diff --git a/dots/bspwm/.config/fish/functions/1080p.fish b/dots/bspwm/.config/fish/functions/1080p.fish new file mode 100644 index 00000000..5b55bf1d --- /dev/null +++ b/dots/bspwm/.config/fish/functions/1080p.fish @@ -0,0 +1,7 @@ +# Easily change the resolution to 1080p +# Note: Also changes DPI, but not for the programs you already have open. +function 1080p + xrandr --output VGA-1 --mode "1920x1080" # Change the resolution + sed -i '/Xft.dpi/c\Xft.dpi: 96' ~/.Xresources # Change the dpi line to 96 + xrdb ~/.Xresources # Reload .Xresources +end diff --git a/dots/bspwm/.config/fish/functions/4k.fish b/dots/bspwm/.config/fish/functions/4k.fish new file mode 100644 index 00000000..bfcb1800 --- /dev/null +++ b/dots/bspwm/.config/fish/functions/4k.fish @@ -0,0 +1,24 @@ +# Easily change the resolution to 4k +# Note: Also changes DPI, but not for the programs you already have open. +# TODO: Change this script to support fish +function 4k + # Get the display type (VGA-1, etc.) + local display=$(xrandr | grep -Eo ".{0,20} connected" | awk '{print $1}') + + # Get the default mode name for 4k + local mode=$(cvt 3840 2160 | grep "Modeline" | awk '{print $2}') + + # If the 4k mode hasn't been added yet + if not (xrandr | grep -q 3840x2160) + + # Create the new mode with cvt settings + xrandr --newmode $(cvt 3840 2160 | grep -o '"3840x2160.*') + + # Add the new mode to the display with xrandr + xrandr --addmode ${display} ${mode} + end + + xrandr --output ${display} --mode ${mode} # Change the resolution to 4k + sed -i '/Xft.dpi/c\Xft.dpi: 180' ~/.Xresources # Change the dpi line to 180 + xrdb ~/.Xresources # Reload .Xresources +end diff --git a/dots/common/.config/fish/functions/lab.fish b/dots/common/.config/fish/functions/lab.fish new file mode 100644 index 00000000..8bdaa6fa --- /dev/null +++ b/dots/common/.config/fish/functions/lab.fish @@ -0,0 +1,11 @@ +# Easily clone and cd into GitLab repositories +# Usage: lab username/repository +function lab --argument-names "path" + if test -n "$path" + git clone git@gitlab.com:$path.git + cd (basename "$path") + else + echo "No repository was specified." + echo "Usage: lab username/repository" + end +end