Defining aliases into a file freeBSD - freebsd

I've seen someone define an alias* in a file (he directly edited a file, and added the alias) in freeBSD, does anyone know which file this is?
I assume those where aliases because he gave them a name, and wrote a command for them, then called them in cli
Only thing that I fould related to aliases is :
alias alias_name "do_something"
And these do not show if I write alias in cli, the output is:
# alias
h (history 25)
j (jobs -l)
la (ls -aF)
lf (ls -FA)
ll (ls -lAF)
The ones I defined don't show here
Which dosen't seem to stick, after I rebooted, the're gone

The file was csh resource script, editing it reveals alias like ll and so on:
ee ~/.cshrc

Related

Change colors on executable files in the terminal (or iTerm2)

How do I change it, so executable files don't have another color, compared to other files? I'm on macOS Sierra (10.12.6). It's the same, both in the regular Terminal:
... or in iTerm2:
It's frustating to look at. If i write chmod -x [FILENAME] then it disappears. But I don't want to change if the files are executable or not, - I want to change the color of executable files. I want my files to look like this (regardless of if it's executable or not):
I tried correcting Anshuman's answer, so it could help people with the potential same challenges. His answer pointed me in the right direction, but was pretty far from the answer to the question. So I'll post it here myself.
The LSCOLORS are set in your ~/.bash_profile (or ~/.zshrc-file, if you use Zshell) for your environment. On this page, then you can experiment a bit with the settings and see which letters changes which colors. It's in your current LSCOLORS that it's setting the color of your executable files to be another color. Here's how you find (and change) that color:
Go to your terminal and write:
echo $LSCOLORS
then it'll print out your current setup, which might be something along these lines:
Gxfxcxdxbxegedabagacad
If you then (in this case) change it to this:
GxfxcxdxDxegedabagacad
Then it would change the colors of the executable files. And what that change comes down to, is which color in your profile, it's pointing to:
set the LSCOLORS environment variable
create an alias for ls so that it shows colors by default
In your ~/.bash_profile add the following:
export LSCOLORS="EHfxcxdxBxegecabagacad"
alias ls='ls -lGH' <-----This shows in list format, follow symlinks colorized
Another way to handle this problem is to simply override "ls --color" altogether, I recently solved this problem with a simple awk script and shell wrapper called "cf".
Then you can create alias for ls like this:
alias ls='_(){ /bin/ls -F -1 -A "$#"|cf|column;};_'
See screenshots and get it from: GitHub
It also has a deb installer

Unable to list all files in $HOME directory

I installed the latest version of cygwin and wanted to list all files in my $HOME direcrory (in paticular .vimrc config file). I type ls -l and see 0 files, but when I try to open the file via vim it's ok. Actually (after 2 TABs):
what's wrong?
In *nix systems, prefixing a name with . causes the item to be hidden.
To include these files when you type ls -l, you will need to include the -a modifier.
You can write this as ls -la for brevity, if you like.
In the future, if you're having trouble with a program, you can type (e.g.) man ls to open the manual pages for (e.g.) ls.

Assign directory to variable in a source file

I am building a source file with some alias to executable files (these are working just fine) and assigning directories to variables in order to get to the directory quicker, with less typing. For example, if I source example.source:
#!/usr/bin/bash
mydir="/path/to/some/dir"
I can get to /path/to/some/dir with
cd $mydir
However, I am not being able to use tab complete to navigate through other sub-directories like I would do by typing the complete path. I mean, if I use the tab key to complete the variable I get cd $mydir but not cd $mydir/ (I have to delete the last space character and manually type the slash / to see the next sub-directories). Hope this is an understandable question. Is there any workaround for this?
EDIT: the linux distribution I'm using is Slackware Linux 3.2.31.c x86_64 GenuineIntel GNU/Linux
EDIT2: GNU bash, version 4.2.37(2)-release
Apparently this feature is starting to be implemented in bash 4.3, release 26-Feb-2014 09:25.
Reading the NEWS file in bash 4.3 I found this:
i. The word completion code checks whether or not a filename
containing a
shell variable expands to a directory name and appends `/' to the word
as appropriate. The same code expands shell variables in command names
when performing command completion.
Unfortunately I cannot do a de novo installation of bash (because I'm working on a server) but I hope this can help others.
If I understand your question, then I believe it can be solved by putting this at the top of your example.source. This will list your contents every-time that you cd.
#!/usr/bin/bash
# Make cd change directories and then list the contents
function cd() {
builtin cd $*;
ls;
}
mydir="/path/to/some/dir"
cd $mydir
My other suggestion is to try to put cd within your alias. Something like this:
mydir="cd /path/to/some/dir"
$mydir

can not open .cshrc after modifying

I am on a RedHat csh.
I just modified ~/.cshrc with a wrong path and resulting in an syntax-error.
my shell just not recognize ls or gedit. So, when I again try to modify, it is not again opening with gedit ~/.cshrc.
When I boot the system it is not starting the profile.
I Have the root access and root profile is fine. Can I edit it from root.
Please help me to remove last two lines i have added to /.cshrc, using root-profile so that it works normal as previous.
thanks.
I'm guessing your PATH isn't getting set properly due to the syntax-error in your .cshrc (assumption since you mention ls isn't working). Try the following from your shell:
echo $PATH
echo is a built-in and should always work. If it returns nothing, is empty, or doesn't include a list of paths similar to /bin, /usr/bin, etc ... then your path is indeed incorrect. Use the full path to gedit on the command line like:
/usr/bin/gedit ~/.cshrc

Where are alias' stored in Ubuntu 10.04

I'm using a command which I don't know where the information is stored.
alias nup='ps ax | grep "nginx"'
Where is this alias saved?
It depends upon your environment and configurations.
For bash, I would generally put it in a .bashrc file that in a home directory.
In ubuntu alias get stored in the .bashrc file.
If you are typing alias update_linux='sudo apt-get update' in the terminal, then it will create an alias temporarily. It works until you close your terminal.
To add an alias permanently you can edit ~/.bashrc and add the alias to it:
gedit ~/.bashrc
and add alias at the end
alias update_linux='sudo apt-get update'
Don't forget to refresh the .bashrc configuration, by running:
source ~/.bashrc
for more details on creating alias you can read following blog: Codebucket.
Try
grep alias ~/.*
grep alias /etc/*
to find most aliases. In /etc/default, /etc/environment, depending on your distribution (I read: ubuntu)/version there might be more in other /etc/ -subdirs.
I am using Ubuntu 14.04, and you may put your aliases directly in .bashrc, but you may also create a file in ~/.bash_aliases, which will hold your aliases separately and load them automatically.
By default, the .bash_aliases file is not there. You will need to create it, but first make sure you create it in the same directory as your .bashrc file
To find your .bashrc, you may use this:
sudo find / -name .bashrc -print
My output was:
/root/.bashrc
/home/ddropik/.bashrc
/etc/skel/.bashrc
As mentioned by OddityOverseer and ranendra, I am probably interested in the one in my home directory, that is /home/ddropik/.bashrc. So I navigate to my home directory, cd ~/
Now create the .bash_aliases file with touch .bash_aliases and then edit it with nano .bash_aliases. Add whatever aliases you want.
You won't be able to use your newly added aliases until you open a new terminal session, or reload your profile, --bash login
It's ussually in a file in your home directory, such as .aliases or something.
The question here is:
if I have an alias named 'shortcut,' how do I find out what file is defining that as an alias?
The best and most user-friendly way to do this is this:
sudo grep -roI alias\ nameOfAliasHere=\' /etc/ /home/yourUserName/
-r tells grep to read everything in the directory, and go through the directories recursively, Without it, grep will complain about what you want to do.
-o means print only the part of the line that matches your string
-I suppresses binary files in the results, because those will not help you find out where your alias is
The backslashes mean "treat the next character as part of the string, instead of the normal way you interpret it"
The command will go through everything, including subdirectories, in your home folder and in /etc
If you want to start with the most likely places, just do your home directory:
sudo grep -roI alias\ nameOfAliasHere=\' /home/yourUserName/
To search everywhere it's likely to be defined or mentioned, which can be handy, this:
sudo grep -oIr alias\ ls=\' / --exclude-dir={sys,proc,srv,media,tmp,sbin,bin,boot,mnt,recovery,run,backups,var}
A lot of things like to make the 'ls' command fancier, for example. Check out the comparison below. I also included 'time' at the beginning for kicks:
You can see that there are a couple places outside of your home dir and /etc that have that alias, and it's also defined in both .alias and .bashrc. Personally, I like to throw my custom aliases in a file called .alias, and then tell everything to source it. If you're having trouble with an alias you're trying to define, that's handy. The things you see in the ~/Downloads and .cache directories won't affect your active aliases. Same with the /usr directory.
The file in /etc/skel is used to create home directories for new users, so anything there doesn't affect you. If something shows up in /etc/profile though, that will.
You can also see that the root user has an alias for ls.

Resources