Created
August 8, 2019 10:36
-
-
Save Darkless012/2e15b414e4ff2d71d78feee50dd67f31 to your computer and use it in GitHub Desktop.
Fish title functions ~/.config/fish/functions/fish_title.fish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# File: ~/.config/fish/functions/fish_title.fish | |
# Strips directory names to single char to save space even more | |
# Requires fish version 2.7.1-1113-ge598cb23 or greater due to `set -a` functionality | |
function fish_title | |
set -l new_pwd | |
# replace home path with ~ | |
set -l cwd (pwd | sed "s:^$HOME:~:") | |
# loop through all folders on cwd, but the last one | |
for x in (echo $cwd | string split '/')[1..-2] | |
set -a new_pwd (string sub -s 1 -l1 $x) | |
end | |
# add full name of the the last (current) directory | |
set -a new_pwd (echo $cwd | string split '/')[-1..-1] | |
# include hostname | |
echo \[(hostname)\] (string join "/" $new_pwd) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# File: ~/.config/fish/functions/fish_title.fish | |
# Strips directory names to 4 chars to save space | |
# Requires fish version 2.7.1-1113-ge598cb23 or greater due to `set -a` functionality | |
function fish_title | |
set -l new_pwd | |
# replace home path with ~ | |
set -l cwd (pwd | sed "s:^$HOME:~:") | |
# loop through all folders on cwd, but the last one | |
for x in (echo $cwd | string split '/')[1..-2] | |
if test (string length $x) -gt 4 | |
set -a new_pwd (string sub -s 1 -l4 $x)^ | |
else | |
set -a new_pwd $x | |
end | |
end | |
# add full name of the the last (current) directory | |
set -a new_pwd (echo $cwd | string split '/')[-1..-1] | |
# include hostname | |
echo \[(hostname)\] (string join "/" $new_pwd) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment