Skip to content

Commit 110fa59

Browse files
Create config.fish
1 parent a6c2068 commit 110fa59

File tree

1 file changed

+231
-0
lines changed

1 file changed

+231
-0
lines changed

config.fish

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
### ADDING TO THE PATH
2+
# First line removes the path; second line sets it. Without the first line,
3+
# your path gets massive and fish becomes very slow.
4+
set -e fish_user_paths
5+
set -U fish_user_paths $HOME/.bin $HOME/.local/bin $HOME/.config/emacs/bin $HOME/Applications /var/lib/flatpak/exports/bin/ $fish_user_paths
6+
7+
### EXPORT ###
8+
set fish_greeting # Supresses fish's intro message
9+
set TERM "xterm-256color" # Sets the terminal type
10+
set EDITOR "emacsclient -t -a ''" # $EDITOR use Emacs in terminal
11+
set VISUAL "emacsclient -c -a emacs" # $VISUAL use Emacs in GUI mode
12+
13+
### SET MANPAGER
14+
### Uncomment only one of these!
15+
16+
### "nvim" as manpager
17+
set -x MANPAGER "nvim +Man!"
18+
19+
### "less" as manpager
20+
# set -x MANPAGER "less"
21+
22+
### SET EITHER DEFAULT EMACS MODE OR VI MODE ###
23+
function fish_user_key_bindings
24+
# fish_default_key_bindings
25+
fish_vi_key_bindings
26+
end
27+
### END OF VI MODE ###
28+
29+
### AUTOCOMPLETE AND HIGHLIGHT COLORS ###
30+
set fish_color_normal brcyan
31+
set fish_color_autosuggestion '#7d7d7d'
32+
set fish_color_command brcyan
33+
set fish_color_error '#ff6c6b'
34+
set fish_color_param brcyan
35+
36+
### FUNCTIONS ###
37+
38+
# Functions needed for !! and !$
39+
function __history_previous_command
40+
switch (commandline -t)
41+
case "!"
42+
commandline -t $history[1]; commandline -f repaint
43+
case "*"
44+
commandline -i !
45+
end
46+
end
47+
48+
function __history_previous_command_arguments
49+
switch (commandline -t)
50+
case "!"
51+
commandline -t ""
52+
commandline -f history-token-search-backward
53+
case "*"
54+
commandline -i '$'
55+
end
56+
end
57+
58+
# The bindings for !! and !$
59+
if [ "$fish_key_bindings" = "fish_vi_key_bindings" ];
60+
bind -Minsert ! __history_previous_command
61+
bind -Minsert '$' __history_previous_command_arguments
62+
else
63+
bind ! __history_previous_command
64+
bind '$' __history_previous_command_arguments
65+
end
66+
67+
# Function for creating a backup file
68+
# ex: backup file.txt
69+
# result: copies file as file.txt.bak
70+
function backup --argument filename
71+
cp $filename $filename.bak
72+
end
73+
74+
# Function for copying files and directories, even recursively.
75+
# ex: copy DIRNAME LOCATIONS
76+
# result: copies the directory and all of its contents.
77+
function copy
78+
set count (count $argv | tr -d \n)
79+
if test "$count" = 2; and test -d "$argv[1]"
80+
set from (echo $argv[1] | trim-right /)
81+
set to (echo $argv[2])
82+
command cp -r $from $to
83+
else
84+
command cp $argv
85+
end
86+
end
87+
88+
# Function for printing a column (splits input on whitespace)
89+
# ex: echo 1 2 3 | coln 3
90+
# output: 3
91+
function coln
92+
while read -l input
93+
echo $input | awk '{print $'$argv[1]'}'
94+
end
95+
end
96+
97+
# Function for printing a row
98+
# ex: seq 3 | rown 3
99+
# output: 3
100+
function rown --argument index
101+
sed -n "$index p"
102+
end
103+
104+
# Function for ignoring the first 'n' lines
105+
# ex: seq 10 | skip 5
106+
# results: prints everything but the first 5 lines
107+
function skip --argument n
108+
tail +(math 1 + $n)
109+
end
110+
111+
# Function for taking the first 'n' lines
112+
# ex: seq 10 | take 5
113+
# results: prints only the first 5 lines
114+
function take --argument number
115+
head -$number
116+
end
117+
118+
# Function for org-agenda
119+
function org-search -d "send a search string to org-mode"
120+
set -l output (/usr/bin/emacsclient -a "" -e "(message \"%s\" (mapconcat #'substring-no-properties \
121+
(mapcar #'org-link-display-format \
122+
(org-ql-query \
123+
:select #'org-get-heading \
124+
:from (org-agenda-files) \
125+
:where (org-ql--query-string-to-sexp \"$argv\"))) \
126+
\"
127+
\"))")
128+
printf $output
129+
end
130+
131+
### END OF FUNCTIONS ###
132+
133+
134+
### ALIASES ###
135+
# navigation
136+
alias ..='cd ..'
137+
alias ...='cd ../..'
138+
alias .3='cd ../../..'
139+
alias .4='cd ../../../..'
140+
alias .5='cd ../../../../..'
141+
142+
# vim and emacs
143+
alias vim='nvim'
144+
alias emacs="emacsclient -c -a 'emacs'"
145+
alias em='/usr/bin/emacs -nw'
146+
alias rem="killall emacs || echo 'Emacs server not running'; /usr/bin/emacs --daemon" # Kill Emacs and restart daemon..
147+
148+
# Changing "ls" to "eza"
149+
alias ls='eza -al --color=always --group-directories-first' # my preferred listing
150+
alias la='eza -a --color=always --group-directories-first' # all files and dirs
151+
alias ll='eza -l --color=always --group-directories-first' # long format
152+
alias lt='eza -aT --color=always --group-directories-first' # tree listing
153+
alias l.='eza -a | egrep "^\."'
154+
alias l.='eza -al --color=always --group-directories-first ../' # ls on the PARENT directory
155+
alias l..='eza -al --color=always --group-directories-first ../../' # ls on directory 2 levels up
156+
alias l...='eza -al --color=always --group-directories-first ../../../' # ls on directory 3 levels up
157+
158+
# pacman and yay
159+
alias pacsyu='sudo pacman -Syu' # update only standard pkgs
160+
alias pacsyyu='sudo pacman -Syyu' # Refresh pkglist & update standard pkgs
161+
alias parsua='paru -Sua --noconfirm' # update only AUR pkgs (paru)
162+
alias parsyu='paru -Syu --noconfirm' # update standard pkgs and AUR pkgs (paru)
163+
alias unlock='sudo rm /var/lib/pacman/db.lck' # remove pacman lock
164+
alias orphan='sudo pacman -Rns (pacman -Qtdq)' # remove orphaned packages (DANGEROUS!)
165+
166+
# get fastest mirrors
167+
alias mirror="sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist"
168+
alias mirrord="sudo reflector --latest 50 --number 20 --sort delay --save /etc/pacman.d/mirrorlist"
169+
alias mirrors="sudo reflector --latest 50 --number 20 --sort score --save /etc/pacman.d/mirrorlist"
170+
alias mirrora="sudo reflector --latest 50 --number 20 --sort age --save /etc/pacman.d/mirrorlist"
171+
172+
# adding flags
173+
alias df='df -h' # human-readable sizes
174+
alias free='free -m' # show sizes in MB
175+
alias grep='grep --color=auto' # colorize output (good for log files)
176+
177+
# ps
178+
alias psa="ps auxf"
179+
alias psgrep="ps aux | grep -v grep | grep -i -e VSZ -e"
180+
alias psmem='ps auxf | sort -nr -k 4'
181+
alias pscpu='ps auxf | sort -nr -k 3'
182+
183+
# Merge Xresources
184+
alias merge='xrdb -merge ~/.Xresources'
185+
186+
# git
187+
alias addup='git add -u'
188+
alias addall='git add .'
189+
alias branch='git branch'
190+
alias checkout='git checkout'
191+
alias clone='git clone'
192+
alias commit='git commit -m'
193+
alias fetch='git fetch'
194+
alias pull='git pull origin'
195+
alias push='git push origin'
196+
alias tag='git tag'
197+
alias newtag='git tag -a'
198+
199+
# get error messages from journalctl
200+
alias jctl="journalctl -p 3 -xb"
201+
202+
# gpg encryption
203+
# verify signature for isos
204+
alias gpg-check="gpg2 --keyserver-options auto-key-retrieve --verify"
205+
# receive the key of a developer
206+
alias gpg-retrieve="gpg2 --keyserver-options auto-key-retrieve --receive-keys"
207+
208+
# change your default USER shell
209+
alias tobash="sudo chsh $USER -s /bin/bash && echo 'Log out and log back in for change to take effect.'"
210+
alias tozsh="sudo chsh $USER -s /bin/zsh && echo 'Log out and log back in for change to take effect.'"
211+
alias tofish="sudo chsh $USER -s /bin/fish && echo 'Log out and log back in for change to take effect.'"
212+
213+
# bare git repo alias for dotfiles
214+
alias config="/usr/bin/git --git-dir=$HOME/dotfiles --work-tree=$HOME"
215+
216+
# termbin
217+
alias tb="nc termbin.com 9999"
218+
219+
# the terminal rickroll
220+
alias rr='curl -s -L https://raw.githubusercontent.com/keroserene/rickrollrc/master/roll.sh | bash'
221+
222+
# Mocp must be launched with bash instead of Fish!
223+
alias mocp="bash -c mocp"
224+
225+
### RANDOM COLOR SCRIPT ###
226+
# Get this script from my GitLab: gitlab.com/dwt1/shell-color-scripts
227+
# Or install it from the Arch User Repository: shell-color-scripts
228+
colorscript random
229+
230+
### SETTING THE STARSHIP PROMPT ###
231+
starship init fish | source

0 commit comments

Comments
 (0)