Some bashrc recommendations and what I use

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right so I get a lot of questions about what kind of stuff I actually have in my bash RC you can get my bash RC of course at my github links in the description or link to my website which has a link to it or something like that but in this video I'm gonna talk about what kind of stuff I have in my bash RC what kind of stuff I might recommend for newer users to have in there and just other stuff about it I will say over time but some people you will see on the internet will have bachelor C's that are like a thousand lines long mine is 61 right now and I was looking at this just a second ago and there's probably a lot more I could clear out of this thing but I so I have the mentality of keeping it very relatively short but I'll tell you what I have in addition to the bash RC which I'll talk about in just one second I guess it's also important to talk about your bash profile so if you don't know if your total newbie right so the bash RC is a list of commands and settings that are gonna run every time you open the terminal your bash are your a bash terminal or something like that or a terminal running bash however you want to think of it and the bash profile is basically what's gonna run whenever you log in and bash is your default shell now one thing about profiles I will say I mention it because it's been a problem for me so this is you can have a bash profile bash underscore profile you can have a just normal dot profile which runs whenever you log in on a TTY and you don't have a bash profile or if you just have sa any kind of other shell or something like that you have Z profile for Z SH you have X profile if you log in in a graphical environment and I find that that all gets very confusing so if you're like me and you often switch between login types or shells or something like that I find it very helpful to do the following and that is I really only have one profile file and then I have my bash profile X profile Z profile they all are just shortcuts they all all are links that go to this one profile file so that's just one thing that I want to this has caused me problems since other people use my dot file so I just want to say that's what I do so anyway you're looking at my profile file here what do I have here I have a lot of environmental settings set my editor set my terminal browser a lot of these are specific to my own dot files I have like I sent my bibliography file as an example just because there are a lot of times I'm running commands and I want to output stuff to my bibliography file and that is this is like my law tech bibliography file where I have like everything all the sources that I cite and I want to output stuff to this file but it's too hard to write out the whole location so I just use a kind of environmental variable you know whatever so I have stuff like that I had my scripts folder to my path if you're a newbie right so your path director you're path variable is a list of all the directories like from which you can run commands without giving the whole location right so if I run our M I can run RM from wherever even though it happens that RM is specifically in user bin so by adding a directory to your path directory you don't have to write off the full location of the command or script or whatever this is the basic note if you don't know some people don't I get a lot of questions about it so might as well mention it so other things I have here in my pro again this is the profile this is only gonna run when I log in this says if I log in on the first TTY and I'm not running I three already start the graphical environment just because I don't have to type type start start X myself because I pretty much always want the graphical environment if that doesn't run or whatever and the profile continues I also if I'm all being the tty remind you I also want since I'm a VIN user I want to have a caps-lock remapped as escape so escape is very accessible so I can get back to normal mode very easily so I actually have it load let me just show you what this looks like I have this little I have this little file here tty maps that lists out command key codes that I want to remap in the tty so I just have it switch and basically just this just says switch caps and escape so if so whenever I'm in the TTY whenever I press this caps-lock it actually performs as an escape so I like having that setting for them and then I also wrote load the wall color scheme in my TTY so that way even if I login in the tty I'm gonna have this kind of color scheme that's easier on the eyes at least easier than the default as far as I'm concerned so that's what I have into my profile let's actually talk about the bash RC so again this is gonna run on login and bash RC is gonna run pretty much whenever you bring up a any kind of bash prompt or terminal running bash so basic settings I have here one thing I found you may have noticed this with a lot of terminals that is if you type ctrl s that actually pauses your terminal and you can well I'm not I might as well no point in showing you what that looks like you just it pauses the terminal it ceases all inputs and you can type whatever and nothing's gonna happen until you press ctrl Q and then it's going to input all those characters that you you put in now this feature is I mean it's it's standard in terminals but I don't like having it just because you know a lot of times I'll accidentally press ctrl s or something or maybe you might want to remap ctrl s to save in vim or something like that I find this so this command just disables control asking and ctrl Q that's all that's for I mean it technically does other stuff but in practice that's what it does um another thing I have that a lot of people like everyone said oh here's someone who who likes CSH be like holla zsh is so great you could just type the directory name and it automatically CDs to it I don't know why people say that because you can do that and bass by just putting in this setting so if I want a CD to my articles directory I can just type in articles now I'm there great so that's that and I also have my history size my bash history I have an infinite I why not I figured I've been doing this for a couple months now and I find it pretty useful so basically all of the commands you log are gonna be in bash history anyway and this just keeps it from deleting old commands now I've been using it for a couple months like and I want to say it's around how much is it well who cares it's it's like around sixty KB or something like that it's so hasn't gotten too big it's not gonna get into Meg's and Meg's and Meg's I figure I'm gonna reform at my computer before that happens but it doesn't matter I got a big harddrive anyway but yeah so that that's something you might want to contemplate and something I don't have in my batch RC but I've thought about doing is you can also put time codes for all your commands in your batch history so if you're running a server or something that might be really useful if something goes wrong you want to check what kind of commands you've run in the past now one honor the other thing here so this is a bunch of lines here this sets my my prompt here so it looks it has this particular color scheme and look appearance but also what this if statement does okay so one thing I should probably explain one thing that I do is if you go to your Etsy dot let see slash password file you can change the home directory of different users and one crazy thing that I've done I don't think this is I don't recommend this as safe it's never it's never bit me in the behind but one thing that I've been doing is I've been using my root user I've given it the home directory of my main user so whenever I run as my root user it actually uses the dot files of my main user and that solves that clears up a bunch of headache in my workflow I'll just say that I don't know if it's a hundred percent safe I don't know if I recommend doing it but the reason I have this if statement here is if I switch to the root user what this if statement does is basically just makes the prompt capital and that's just so I know so it's visually obvious if I'm running something as a root user so I don't run any commands that I think are questionable that's just what that does and again this only matters if you have I mean if you just want my prompt you can just steal this part right here and throw it in your batch RC but I just want to have the prompt different for the root user and that that's why I do it you know anyway some basic aliases and stuff so one thing on aliases or you know aliases if you don't know they're just shortcuts for commands if you're a new user right so I have to type sudo pac-man a whole lot because I'm often using pac-man for stuff and I just abbreviate that as P so whenever if I want to upgrade or something like that I can just do P and then give it the options now one thing if you're a new user and this applies of course the Arch Linux running pac-man or maybe Ubuntu or Debian running app git or something like that if you're a new user here's what a lot of new users will do okay let me let me just show show you alright let's say you're running Ubuntu okay so sudo apt-get install I know that's the the the command for install a program so I'm gonna give an alias for it that is install or something like that or o upgrade is you know I want to sudo apt-get blah blah blah and what is it upgrade or whatever so the tendency of a lot of new users is to make aliases for very specific commands or sub commands specifically because this is apt-get and then a sub command or however you want to think of it a lot of users will be tempted to make aliases for very specific commands and I sort of recommend against that just because I mean on one of all two reasons first off you're not gonna remember or you'll gradually forget what the actual command is you're not gonna remember sudo apt-get whatever it's sort of it's not something you actually have to remember and also when you want a specific setting to the command you'll often have to not use your alias or do something weird so when I the reason I say this is most of my aliases are mostly just abbreviations of things that general commands like all of these are just commands right systemctl them ranger stuff like that I don't recommend making aliases for sub commands or commands with specific options unless you just always want those options so I don't recommend you having an alias for upgrade an alias for install program I recommend you just learn the command and learn the syntax to that command and if you want to abbreviate it if you want to abbreviate the command itself in an alias or add in sudo that's fine but I think it's not a super good habit to put a whole bunch of the very specific command in an alias I I just in my experience keep on like I did this when I first started using Linux or any kind of UNIX system and I just found that it was it wasn't a good habit I didn't really learn things as fast and I gotten the the mindset of not looking at the command itself and learning about it but making aliases to do these specific things that I wanted and that's not a good habit so pretty much all of my aliases are abbreviations now if you do want to put specific options that's fine but I recommend to do it only when you want when you always want those options so I have an alias for make directory and I give it the P and the V options so P means make a parent directory if if that doesn't exist and V means visual just give me feedback like the directory was created now I pretty much always want those options when I run make directory so I can have an alias for that I don't mind that and I have some down here I'll talk about those in a second but in general just I recommend against making aliases for very specific commands that you're gonna run in very specific circumstances I recommend against that just use aliases to abbreviate or always enforce some options and nothing else so similar to the make directory thing this is other options that I always like having so LS give it a couple let's see I think this is no quotes and this is human readable file sizes and I also have LS have color auto and group directories first so group directories first means pretty much what it sounds like I mean let's say I even let's say I LS or LS my documents la tech folder or something like that it's going to base it first off there are subfolders here so it's gonna list the folders first that's group directories first and you'll also see well there's not color here but there's it's different here and that's part of that excuse me so I really just always one color or well I should say color Auto means if you output the terminal it's going to appear as color but if you output LS to like a file it's not gonna put the color codes with that and you don't want that so I have color Auto for that and same thing with grep let's say I have see I grew up a file let's say grab global grep the sequence grep from my bash RC all right so that's just automatically highlight if you put color Auto that'll just automatically highlight all the matches so that's something you might want to contemplate and another thing I have is this isn't a cat command but sometimes I want to cat out a a file and with the sort of file hi or syntax highlighting and I have this command now this isn't cat but this is highlight which is another command you can download which has the option of outputting stuff in particular syntax so what you can do is let's say I think of a file that I could do this too let's say I run the alias C cat on scripts shortcuts that Sh and that's gonna cat it out in effect and again it's not really cat it's really highlight but it's gonna output this file with all the syntax highlighted now the way highlight works I'll just go and say that it's not gonna work if you if I run it on let's say my bash RC excuse me my bash RC here it's gonna say I don't know what syntax to run so it's not going to earn actually maybe maybe it'll work with force I don't even know okay yeah no it doesn't work nevermind yes so this will only work on files that have a particular extension and it can get the file type from the extension and assume the syntax otherwise you have to manually give it syntax and at that point it's all worth it but this is just a nice alias to have just to have it just because occasionally I want to output something and with the file extension and see what it looks like with syntax highlighting anyway some other things that I have so youtube download so if you don't know what YouTube DL is it does exactly what it sounds like you just run this command and run it on a youtube link to either a channel or a video or a playlist and it downloads that channel or video or playlist so I have no excuse me so I have a couple alias aliases for it I always want these settings so add metadata means when I download the video put them in it and put the metadata with the file you know be that the author name the video title and stuff like even I think it even has like viewcount and stuff like that and I also give it these other options I is let's see what is I I is ignore errors yeah so if like a video in a playlist mix messes up it continues anyway and see is for continue if you if let's say like the download breaks in the middle you can just rerun the command and it's gonna pick up where it started and so I have YouTube YT for YouTube DL and yta for download with audio and and you might say okay well this sort of contem contradicts what you said before and in a lot of ways well the idea behind it is I have to type all of this I'm gonna want this every time I run youtube-dl and it'd be a pain just to add in that extra option so I just have two aliases for it but I know youtube-dl by heart anyway so that's fine but you can check out the manual for it if you want to add in some other options or something it has there are some other cool stuff you can have it download thumbnails and stuff aside from that I also have YouTube viewer which I just abbreviate as capital y capital T and I have some other so I don't actually use this stuff anymore I used to have speedometer I show you I might still have this installed mine which I can see if ya I still have speedometer installed and it just gives you your well it's not loading anything right now it gives you your internet usage or whatever so oh no I'm not an Ethernet that's why nevermind but I don't actually use this and they're only recenter had these aliases is because I always forget what profiles I had on whatever computer I'm using so I just have them okay I got mail I just have them in my bash RC so the reason I have these here and not necessarily because I can't remember speedometer but because I can't remember my whatever profiles I have on each of my computers anyway Star Wars you can run that and see what happens and the only other things I have is a couple copy commands for law tech so I have la tech templates and I sometimes just want to copy them to a new location to create a new file so I have shortcuts for that don't actually use this anymore I should delete this and source my shortcuts file if you don't know what that is you can check out my video on my short I think it's whatever last video I did on that it was a couple videos ago and this thing right here this is for downloading stuff from SCI hub if you don't know what that is so basically SCI hub you can feed it a link to an academic article that's pay walled and it will Sai hub will like bypass the paywall basically and this command you can usually give it a link and it will download the PDF but sometimes you need to capture something so it doesn't actually work so it's better to actually you Sai hub manually anyway that's what I have in my bash RC I should say I have other stuff in my general environment but that is stuff that I have in specific shell scripts that are in my scripts folder so you can check again you can check my github out for that kind of stuff but anyway that's this has been a preview all of my bash RC and bash profile you can check them out on the github have any questions ask them and that's all perfect time to get a phone call I'll see you guys next time
Info
Channel: Luke Smith
Views: 90,310
Rating: 4.9375296 out of 5
Keywords: script, tutorial, programming, code, editor, pacman, terminal, escape, configure, macos, ubuntu, bash, arch, shell, not related, system, administration, aur, luke smith, gnu, linux, unix, path, settings, root, vim, technology, rc files, server, gentoo, dotfiles, /g/, install, rc, configuration, zsh, computer, sysadmin, prompt, podcast, caps, new, bsd, programs, debian, config, sh, apt-get
Id: _UrDsbs0-OE
Channel Id: undefined
Length: 19min 16sec (1156 seconds)
Published: Mon Oct 01 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.