AstonJ

AstonJ

Just noticed mine has gotten quite unwieldy and should probably be split into multiple files - but curious how big everyone else’s is!

(Mine’s 1304 lines! :100:)

Showing Posts 1 to 10

arcanemachine

arcanemachine

$ wc -l .bashrc 
290 .bashrc

About 130 of those lines are mostly default Ubuntu stuff.

I honestly thought it would be bigger than that…

split into multiple files… 1304 lines!

Dude, you have a problem.

BartOtten

BartOtten

Your rc is larger than my emacs config (without comments). Curious what is in it.

sodapopcan

sodapopcan

Mine is 285 including comments and a bit of junk I should delete. It’s config, very few aliases, and otherwise functions for my prompt as I don’t use ohmyzsh or any such thing. Also very curious why yours is so big :sweat_smile:

AstonJ

AstonJ OP

My rc is definitely in need of cleaning up, and I definitely have some unused (and commented out functions in it) but to give you an idea why it’s so big:

  • First couple hundred lines are aliases
  • I have a lot of functions (which probably really should be their own scripts)

For example I have a lot of functions like this - which are longer than they might otherwise be because of the number of servers I administer:

upload_file() {
  server=$3
	if [ -z "$3" ]; then
		scp -P (port number) $1 root@$FIRST_SERVER:$2
  elif [[ $server == "second" ]]; then
    scp -P (port number) $1 root@$SECOND_SERVER:$2
	elif [[ $server == "third" ]]; then
		scp -P (port number) $1 root@$THIRD_SERVER:$2
	elif [[ $server == "fourth" ]]; then
		scp -P (port number) $1 root@$FOURTH_SERVER:$2
	elif [[ $server == "fifth" ]]; then
		scp -P (port number) $1 root@$FIFTH_SERVER:$2
  ...
}

upload_file_from_desktop() {
  server=$3
	if [ -z "$3" ]; then
		scp -P (port number) /Users/Aston/Desktop/$1 root@$FIRST_SERVER:$2
	elif [[ $server == "second" ]]; then
		scp -P (port number) /Users/Aston/Desktop/$1 root@$SECOND_SERVER:$2
  elif [[ $server == "third" ]]; then
    scp -P (port number) /Users/Aston/Desktop/$1 root@$THIRD_SERVER:$2
  elif [[ $server == "fourth" ]]; then
    scp -P (port number) /Users/Aston/Desktop/$1 root@$FOURTH_SERVER:$2
  elif [[ $server == "fifth" ]]; then
    scp -P (port number) /Users/Aston/Desktop/$1 root@$FIFTH_SERVER:$2
  ...
}

download_file() {
  server=$2
	if [ -z "$2" ]; then
		scp -P (port number) root@$FIRST_SERVER:$1 /Users/Aston/Desktop
	elif [[ $server == "second" ]]; then
		scp -P (port number) root@$SECOND_SERVER:$1 /Users/Aston/Desktop
	elif [[ $server == "third" ]]; then
		scp -P (port number) root@$THIRD_SERVER:$1 /Users/Aston/Desktop
	elif [[ $server == "fourth" ]]; then
		scp -P (port number) root@$FOURTH_SERVER:$1 /Users/Aston/Desktop
	elif [[ $server == "fifth" ]]; then
		scp -P (port number) root@$FIFTH_SERVER:$1 /Users/Aston/Desktop
	fi
}

upload_directory() {
  server=$3
	if [ -z "$3" ]; then
		scp -P (port number) -r $1 root@$FIRST_SERVER:$2
	elif [[ $server == "second" ]]; then
		scp -P (port number) -r $1 root@$SECOND_SERVER:$2
	elif [[ $server == "third" ]]; then
		scp -P (port number) -r $1 root@$THIRD_SERVER:$2
	elif [[ $server == "fourth" ]]; then
		scp -P (port number) -r $1 root@$FOURTH_SERVER:$2
	elif [[ $server == "fifth" ]]; then
		scp -P (port number) -r $1 root@$FIFTH_SERVER:$2
  ...
}

upload_directory_contents() {
  server=$3
	if [ -z "$3" ]; then
		scp -P (port number) -r $1/* root@$FIRST_SERVER:$2
	elif [[ $server == "second" ]]; then
		scp -P (port number) -r $1/* root@$SECOND_SERVER:$2
	elif [[ $server == "third" ]]; then
		scp -P (port number) -r $1/* root@$THIRD_SERVER:$2
	elif [[ $server == "fourth" ]]; then
		scp -P (port number) -r $1/* root@$FOURTH_SERVER:$2
	elif [[ $server == "fifth" ]]; then
		scp -P (port number) -r $1/* root@$FIFTH_SERVER:$2
  ...
}

upload_directory_from_desktop() {
  server=$3
	if [ -z "$3" ]; then
		scp -P (port number) -r /Users/Aston/Desktop/$1 root@$FIRST_SERVER:$2
	elif [[ $server == "second" ]]; then
		scp -P (port number) -r /Users/Aston/Desktop/$1 root@$SECOND_SERVER:$2
	elif [[ $server == "third" ]]; then
		scp -P (port number) -r /Users/Aston/Desktop/$1 root@$THIRD_SERVER:$2
	elif [[ $server == "fourth" ]]; then
		scp -P (port number) -r /Users/Aston/Desktop/$1 root@$FOURTH_SERVER:$2
	elif [[ $server == "fifth" ]]; then
		scp -P (port number) -r /Users/Aston/Desktop/$1 root@$FIFTH_SERVER:$2
  ...
}

upload_directory_contents_from_desktop() {
  server=$3
	if [ -z "$3" ]; then
		scp -P (port number) -r /Users/Aston/Desktop/$1/* root@$FIRST_SERVER:$2
	elif [[ $server == "second" ]]; then
		scp -P (port number) -r /Users/Aston/Desktop/$1/* root@$SECOND_SERVER:$2
	elif [[ $server == "third" ]]; then
		scp -P (port number) -r /Users/Aston/Desktop/$1/* root@$THIRD_SERVER:$2
	elif [[ $server == "fourth" ]]; then
		scp -P (port number) -r /Users/Aston/Desktop/$1/* root@$FOURTH_SERVER:$2
	elif [[ $server == "fifth" ]]; then
		scp -P (port number) -r /Users/Aston/Desktop/$1/* root@$FIFTH_SERVER:$2
  ...
}

download_directory() {
  server=$2
	if [ -z "$2" ]; then
		scp -P (port number) -r root@$FIRST_SERVER:$1 /Users/Aston/Desktop
	elif [[ $server == "second" ]]; then
		scp -P (port number) -r root@$SECOND_SERVER:$1 /Users/Aston/Desktop
	elif [[ $server == "third" ]]; then
		scp -P (port number) -r root@$THIRD_SERVER:$1 /Users/Aston/Desktop
	elif [[ $server == "fourth" ]]; then
		scp -P (port number) -r root@$FOURTH_SERVER:$1 /Users/Aston/Desktop
	elif [[ $server == "fifth" ]]; then
		scp -P (port number) -r root@$FIFTH_SERVER:$1 /Users/Aston/Desktop
  ...
}

Quite a large portion of the file is actually made up of push functions, and while I have some general functions which can handle smaller more basic sites, with commands like:

push pragprog ef # push pragprog giveaway to this forum
push manning efs # push manning giveaway to erlangforums
push pragmaticstudio dt # push pragmaticstudio giveaway to Devtalk
push efs  # push elixir forum sponsors site
etc

For bigger sites the push functions are more involved, as they need to: turn the site off (BRB page) build assets, upload files/assets, run migrations, check permissions, run seeds if given the appropriate flag, turn site back on, etc. So these get a function each (which I could call from the main push function).

And then I have some random functions like:

push_devtalk_coming_soon() {
  upload_directory_contents /Users/Aston/Sites/devtalk/comingsoon/ /home/devtalk.com/public/
}

push_erlang_coming_soon() {
  upload_directory_contents /Users/Aston/Sites/Erlang\ Forums/Comingsoon/ /home/hello.erlangforums.com/public/
}

xmas_graphics_up() {
  scp -P (port number) -r /Users/Aston/Sites/site-name/site-name\ 2016/Christmas\ graphics/xmas-graphics/interface/* root@$FIRST_SERVER:/home/site-name/public/images/interface/
  scp -P (port number) -r /Users/Aston/Sites/site-name2/Christmas\ graphics/xmas-graphics/interface/* root@$FIRST_SERVER:/home/site-name2/public/images/ovinterface/
  scp -P (port number) -r /Users/Aston/Sites/site-name3/Christmas\ graphics/xmas-graphics/interface/* root@$FIRST_SERVER:/home/site-name3/public/images/interface/
  ...
}

xmas_graphics_down() {
  scp -P (port number) -r /Users/Aston/Sites/site-name/site-name\ 2016/Christmas\ graphics/normal-graphics/interface/* root@$FIRST_SERVER:/home/site-name/public/images/interface/
  scp -P (port number) -r /Users/Aston/Sites/site-name2/Christmas\ graphics/normal-graphics/interface/* root@$FIRST_SERVER:/home/site-name2/public/images/ovinterface/
  scp -P (port number) -r /Users/Aston/Sites/site-name3/Christmas\ graphics/normal-graphics/interface/* root@$FIRST_SERVER:/home/site-name3/public/images/interface/
  ...
}

I’m sure I could improve a lot of it (eg: just use numbers instead of words for servers) but it’s not a huge priority for me right now…

nikfp

nikfp

I’m also surprised at the size of your file, mine’s about 145 lines and includes some functions for:

  • Watching an elixir directory and running the code again on changes (used primarily for Advent of Code the last couple years)
  • Watching an elixir dir and running “mix test” on changes
  • a hand rolled tmux fuzzy find / session starter
  • All of my aliases, env var exports, path additions, etc
  • logic to custom load my prompt theme based on OS theme (light or dark mode)

I thought it was overgrowing tbh. I guess not?

NobbZ

NobbZ

$ wc -l .config/zsh/.zshrc
99 .config/zsh/.zshrc

I’m surprised it’s this big. Though indeed, I can explain about any of those lines and why it is there.

But can’t copy the full file, as I’m on mobile.

Also that’s just one computer, the other is currently offline.

dimitrije

dimitrije

Hi @AstonJ , I can suggest trying out .ssh/config https://man.freebsd.org/cgi/man.cgi?query=ssh_config&sektion=5&apropos=0&manpath=FreeBSD+14.3-RELEASE+and+Ports

With combination with rsync https://man.freebsd.org/cgi/man.cgi?query=rsync&apropos=0&sektion=0&manpath=FreeBSD+14.3-RELEASE+and+Ports&arch=default&format=html

I do also administer few server on daily basis, and with .ssh/config and rsync I’ve minimized a lot of typing and erros.

Just an idea as I was in similar situation.

AstonJ

AstonJ OP

Thanks Dimitrije :icon_biggrin:

How are you using .ssh/config? (How do you think it could help me?)

I’ve used rsync in the past (eg for Jekyll sites) but ended up preferring scp (I can’t remember exactly why now tho :icon_redface:)

jswanner

jswanner

Aston, you didn’t ask about fish, and its configuration is fairly different than bash/zsh, but here you go…

wc -l .config/fish/config.fish .config/fish/functions/*
102 total

Almost none of those lines were added to those files by me (maybe ~10 lines I actually wrote), most of it came from me using fish functions from the command line and it writing to those files.

Assuming you have environment variables you are exporting from your rc file, fish has a dedicated file for those, and most of mine are for configuring fish itself. And again, I didn’t write any of those lines, most came from running fish_config, the rest from setting variables from the command line:

wc -l .config/fish/fish_variables
68
cat .config/fish/fish_variables | grep -v fish | wc -l
16
AstonJ

AstonJ OP

Sorry Jacob - every shell user is welcome to join in :icon_biggrin: (I’ve edited the title and tags)

Where Next? Top

Trending in Dev Env & Tools Top

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews