-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.fish
More file actions
178 lines (153 loc) · 6.36 KB
/
config.fish
File metadata and controls
178 lines (153 loc) · 6.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
set --local SCRIPTDIR (dirname (status --current-filename))
# SETUP
mkdir -pv ~/bin
if command --query uname; and string match --ignore-case --quiet 'Darwin' (uname); and not test -e ~/.hushlogin
# removes an annoying message in new terminals in OSX
touch ~/.hushlogin
end
fish_add_path --global --path --move --append "$HOME/.local/bin"
fish_add_path --global --path --move --append "$HOME/bin"
fish_add_path --global --path --move --append "$SCRIPTDIR/scripts"
fish_add_path --global --path "$HOME/.cargo/bin"
fish_add_path --global --path "$HOME/.local/npm-packages/bin"
set fish_function_path "$SCRIPTDIR/fish.d" $fish_function_path
if command --query nvim
set --global --export VISUAL nvim
set --global --export MANPAGER 'nvim +Man!'
else
set --global --export VISUAL vi
end
set --global --export EDITOR "$VISUAL"
set --global --export __fish_prompt_fade_left "░▒▓"
set --global --export __fish_prompt_fade_left_inverted "▓░▒"
set --global --export __fish_prompt_fade_right "▓▒░"
set --global --export __fish_prompt_fade_right_inverted "░▒▓"
set --global --export __fish_prompt_powerline_arrow_left ""
set --global --export __fish_prompt_powerline_arrow_left_inverted ""
set --global --export __fish_prompt_powerline_arrow_right ""
set --global --export __fish_prompt_powerline_arrow_right_inverted ""
set --global --export __fish_prompt_powerline_rounded_left ""
set --global --export __fish_prompt_powerline_rounded_left_line ""
set --global --export __fish_prompt_powerline_rounded_right ""
set --global --export __fish_prompt_powerline_rounded_right_line ""
set --global --export __fish_prompt_powerline_triangle_left ""
set --global --export __fish_prompt_powerline_triangle_left_swap ""
set --global --export __fish_prompt_powerline_triangle_right ""
set --global --export __fish_prompt_powerline_triangle_right_swap ""
if set --query __fish_prompt_no_powerline
set --global --export __fish_prompt_joiner "$__fish_prompt_fade_right"
else
set --global --export __fish_prompt_joiner "$__fish_prompt_powerline_triangle_right"
end
function fish_prompt
# we need to do this first or we will clobber it with other exit codes
set --function lastexit $status
set --function sections
set --function background_colors
set --function foreground_colors
# calculates fish hostname once as it will not change
if not set --query __fish_prompt_hostname
set --global --export __fish_prompt_hostname (hostname | cut -d . -f 1)
end
# user@hostname, to make ssh sessions more clear
if test $COLUMNS -ge 100
set sections $sections "$USER@$__fish_prompt_hostname"
set background_colors $background_colors magenta
set foreground_colors $foreground_colors black
end
# Check if we are in a tmux prompt, display position if so
if test -n "$TMUX"
set sections $sections (tmux display-message -p '#I/#{session_windows}')
set background_colors $background_colors blue
set foreground_colors $foreground_colors black
end
# time of last prompt
if test $COLUMNS -ge 80
set sections $sections (date '+%m/%d %H:%M')
set background_colors $background_colors white
set foreground_colors $foreground_colors black
end
# working directory
set sections $sections (prompt_pwd)
set background_colors $background_colors green
set foreground_colors $foreground_colors black
# exit status, if not 0
if not test $lastexit -eq 0
set sections $sections "$lastexit"
set background_colors $background_colors red
set foreground_colors $foreground_colors black
end
if fish_is_root_user
set sections $sections '#'
set background_colors $background_colors yellow
set foreground_colors $foreground_colors black
end
set sections[1] " $sections[1]"
set background_colors $background_colors normal # one extra so we don't have any access issues
for i in (seq (count $sections))
echo -n -s \
(set_color $foreground_colors[$i] --background $background_colors[$i])\
$sections[$i]" "\
(set_color $background_colors[$i] --background $background_colors[(math $i + 1)])\
"$__fish_prompt_joiner "
end
echo -s -n (set_color normal)
if set --query __fish_prompt_no_powerline
echo -s -n (set_color $background_colors[-2])'$ '(set_color normal)
end
end
# settings for __fish_git_prompt
set --export __fish_git_prompt_show_informative_status 1
set --export __fish_git_prompt_describe_style branch
set --export __fish_git_prompt_showcolorhints 1
set --export __fish_git_prompt_showdirtystate 1
set --export __fish_git_prompt_showstashstate 1
set --export __fish_git_prompt_showuntrackedfiles 1
set --export __fish_git_prompt_showupstream informative
set --export __fish_git_prompt_char_stateseparator ' '
set --export __fish_git_prompt_char_cleanstate 'ok'
set --export __fish_git_prompt_color_cleanstate 'cyan'
set --export __fish_git_prompt_color_cleanstate_done 'normal'
set --export __fish_git_prompt_char_dirtystate '*'
set --export __fish_git_prompt_char_invalidstate '#'
set --export __fish_git_prompt_char_stagedstate '+'
set --export __fish_git_prompt_char_stashstate '$'
set --export __fish_git_prompt_char_untrackedfiles '%'
set --export __fish_git_prompt_char_upstream_ahead '>'
set --export __fish_git_prompt_char_upstream_behind '<'
set --export __fish_git_prompt_char_upstream_diverged '<>'
set --export __fish_git_prompt_char_upstream_equal '='
function fish_right_prompt --description="Shows the git status, if applicable."
fish_git_prompt
end
# suggestions display
set --global --export fish_pager_color_completion normal
set --global --export fish_pager_color_description green
set --global --export fish_pager_color_prefix normal --underline
set --global --export fish_pager_color_progress green
set --global --export fish_pager_color_selected_background -r
# brew settings
if command --query brew
set --global --export HOMEBREW_AUTO_UPDATE_SECS (math "60 * 60 * 24 * 7")
set --global --export HOMEBREW_NO_ANALYTICS
if command --query bat
set --global --export HOMEBREW_BAT 1
end
end
if not command --query g
alias g=git
end
# npm settings
set --local npmrc_file "$HOME/.config/npmrc"
if test -e "$npmrc_file"
set --local npmrc (cat "$npmrc_file")
if not string match --quiet --entire 'send-metrics="' "$npmrc"
echo 'send-metrics=false' >> "$npmrc_file"
end
if not string match --quiet --entire 'fund="' "$npmrc"
echo 'fund=false' >> "$npmrc_file"
end
if not string match --quiet --entire 'cache="' "$npmrc"
echo 'cache=~/.cache/npm' >> "$npmrc_file"
end
end